css如何设置圆角
时间:2021-04-30
来源:互联网
标签:
今天PHP爱好者给大家带来css如何设置圆角方法,在css中,可以使用“border-radius”属性为p元素添加圆角边框,设置圆角效果。该属性按照左上角,右上角,右下角,左下角的顺序设置圆角值,四个值相同时可省略其余三个值。

css如何设置圆角
本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。
方法1:
圆角边框(border-radius)的基本用法:
圆角边框的最基本用法就是设置四个相同弧度的圆角
boder-top-left-radius:30px; //左上角
boder-top-right-radius:30px; //右上角
boder-bottom-left-radius:30px; //右下角
boder-bottom-right-radius:30px; //左下角
如果这四个弧度的圆角相同,可以写成:
border-radius:30px;
例子:
css部分:
.p1{
margin:0 auto;
background: darkcyan;
width:200px;
height:200px;
border:2px solid darkslategray;
border-radius:30px;
text-align: center;
line-height: 200px;
}
效果如图:

方法2:
圆角边框也可以使用百分比作为单位,比如:将一个正方形的圆角边框设置为50%,那么就会形成一个圆,不过使用百分比与像素并不能等效。
注意:百分比大于50%后,形状就不会再变化了,圆角的半径不能超过宽/高的一半
例子:
css部分:
.box1{
width:200px;
height:200px;
margin: 30px auto;
border: 2px solid #e4007e;
text-align: center;
line-height: 200px;
font-weight: bold;
font-size: 24px;
background: burlywood;
border-radius: 50%;//圆角百分比
}
效果如图:

方法3:
既然使用圆角边框可以绘制出一个圆,同样也可以绘制出一个椭圆。
例子:
css部分:
.box2{
width:200px;
height:300px;
margin: 30px auto;
border: 2px solid #e4007e;
text-align: center;
line-height: 200px;
font-weight: bold;
font-size: 24px;
background: burlywood;
border-radius: 100px/150px;
}
效果如图:

方法4:
设置不同弧度的圆角
例子:
css部分:
#box4{
width:500px;
position: relative;
margin:30px auto;
}
.p4,.p5,.p6,.p7{
width:200px;
height:200px;
text-align: center;
color:seagreen;
font-size: 26px;
line-height: 200px;
background: yellowgreen;
border:2px solid darkslategray;
float:left;
margin:20px;
}
.p4{border-top-left-radius: 40px;}
.p5{border-top-right-radius: 20px;}
.p6{border-bottom-left-radius: 30px;}
.p7{border-bottom-right-radius: 10px;}
效果如图:

注意事项
百分比大于50%后,形状就不会再变化了,圆角的半径不能超过宽/高的一半。
以上就是css如何设置圆角的详细内容,更多请关注php爱好者其它相关文章!
-
什么是无理数 常见的无理数有哪些 无理数和有理数的区别 时间:2025-11-19 -
Linux中软连接和硬链接的区别、优缺点和应用场景等 时间:2025-11-19 -
什么是Hypervisor Hypervisor虚拟机监控程序详解 时间:2025-11-19 -
numeric是什么数据类型 decimal和numeric的区别 时间:2025-11-19 -
Java中public class和class的区别 时间:2025-11-19 -
Android中Activity跳转的两种实现方法 时间:2025-11-19
今日更新
-
上单行为是什么梗梗姐姐 揭秘游戏圈爆笑名场面真相
阅读:18
-
yy歪歪漫画官方主入口-yy漫画最新首页地址
阅读:18
-
币安风控Meme币交易原因解析及应对策略
阅读:18
-
yy漫画首页入口-热门章节一键畅读
阅读:18
-
超星网络学生登录入口 超星学生通官网网页版快速登录
阅读:18
-
币安风控申诉被拒的5大关键原因及解决方案
阅读:18
-
揭秘上等马梗出处:职场人秒懂的暗号文化,3秒get社畜生存法则
阅读:18
-
《龙骑士学园》官方入口地址
阅读:18
-
126邮箱登录入口-126邮箱网页版快速登录
阅读:18
-
币安风控机制是否受交易量阈值影响解析
阅读:18










