四、圆角 border-radius

四、圆角 border-radius

4.1 像素表示法:

1
2
3
4
5
6
7
8
.box {
width: 200px;
height: 200px;
background-color: #eee;
margin: 50px auto;
/* 圆角 20px 表示以 20px为半径画圆的弧度*/
border-radius: 20px;
}

NU20tx.png

4.1.1 可以进行拆分:从左上角开始,顺时针方向

1
2
3
4
5
6
7
.box {
width: 200px;
height: 200px;
background-color: red;
margin: 50px auto;
border-radius: 20px 40px 60px 80px;
}

NU22Bd.png

1
border-radius: 20px 80px;

NU2I9f.png

1
border-radius: 20px 80px 40px;

NU27jg.png

4.1.2 按角度拆分

必须先写上下,再写左右

1
border-top-left-radius: 20px;

NU2jNq.png

4.1.3 圆形

值为边长的一半(极限)或一半以上

1
2
3
4
5
6
7
8
9
10
.box {
width: 200px;
height: 200px;
background-color: red;
margin: 50px auto;

border-radius: 100px;

border-radius: 203343430px;
}

NURFb9.png

4.1.4 胶囊型

圆角四个角度都设置,紧着短边来(极限是短边一半)(胶囊型)

1
2
3
4
5
6
7
.box {
width: 200px;
height: 100px;
background-color: red;
margin: 50px auto;
border-radius: 100px;
}

NURMKe.png

4.1.5 半圆

如果有些角度不设置圆角,会有更多的边转为圆角,极限是短边全部(半圆)

1
2
3
4
5
6
7
.box {
width: 200px;
height: 100px;
background-color: red;
margin: 50px auto;
border-radius: 100px 100px 0px 0px;
}

NURt8f.png

1
border-radius: 0px 0px 100px 100px;

NURwrQ.png

4.2 百分数表示法

4.2.1 圆形

正方形,极限50%

1
2
3
4
5
6
7
.box {
width: 200px;
height: 200px;
background-color: lightblue;
margin: 50px auto;
border-radius: 50%;
}

NURs5q.png

4.2.2 椭圆

长方形,极限50%

1
2
3
4
5
6
7
.box {
width: 200px;
height: 100px;
background-color: lightblue;
margin: 50px auto;
border-radius: 50%;
}

NURIaR.png

4.2.3 树叶形

有些角度不设置,极限100%

1
2
3
4
5
6
7
.box {
width: 200px;
height: 100px;
background-color: lightblue;
margin: 50px auto;
border-radius: 100% 0 100% 0;
}

NURXse.png

点击查看

本文标题:四、圆角 border-radius

文章作者:Mango

发布时间:2020年06月30日 - 21:27:45

最后更新:2020年06月30日 - 21:44:19

原始链接:https://mango185.github.io/post/71a638c8.html

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

-------------------本文结束 感谢您的阅读-------------------