border-radius制作圆形,半圆形,扇形,椭圆

使用border-radius 制作圆形有两点技巧:

(1)元素的宽高形同

(2)border-radius值为宽或高的一半,或者直接设置为50%;

制作半圆大同小异,只是圆角方位配合的问题。

下面仅给出示例:

html代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link href="D:\myweb\css\3-19-1.css" type="text/css" rel="stylesheet">
</head>
<body>
    <div class="div"></div>
 
    <div class="semicircle top">上半圆</div>
    <div class="semicircle right">右半圆</div>
    <div class="semicircle bottom">下半圆</div>
    <div class="semicircle left">左半圆</div>
</body>
</html>
css代码:

.div{
    width200px;
    height200px;
    border:2px  orange solid;
    border-radius50%;
}
.semicircle{
    background-colororange;
    margin30px;
}
.top{
    width100px;
    height50px;
    border-radius50px 50px 0 0;
}
.right{
    width50px;
    height100px;
    border-radius0 50px 50px 0;
}
.bottom{
    width100px;
    height50px;
    border-radius0 0 50px 50px;
}
.left{
    width50px;
    height100px;
    border-radius50px 0 0 50px;
}

效果如下:


制作扇形遵循三同一不同的原则,三同就是宽高半径相同,一不同就是圆角位置不同。

.div{
    width200px;
    height200px;
    border:2px  orange solid;
    border-radius50%;
}
.semicircle{
    background-colororange;
    margin30px;
}
.top{
    width100px;
    height100px;
    border-radius100px 0 0 0;
}
.right{
    width100px;
    height100px;
    border-radius0 100px 0 0;
}
.bottom{
    width100px;
    height100px;
    border-radius0 0 100px 0;
}
.left{
    width100px;
    height100px;
    border-radius0 0 0 100px;
}

椭圆:

.semicircle{
    background-colororange;
    margin30px;
}
.top{
    width100px;
    height50px;
    border-radius100px/50px;
}
.right{
    width50px;
    height100px;
    border-radius50px/100px;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值