border-radius:10px; /* 所有角都使用 半 径为10px的 圆 角 */
border-radius: 5px 4px 3px 2px; /* 四个半径值分别是左上角、右上角、 右下角 和左下角,顺时针 */
不要以为border-radius的值只能用px单位,你还可以用百分比 或者 em,但兼容性目前还不太好。
实心上半圆:
方法:把高度(h ei ght)设为 宽 度(width)的一半,并且只设置左上角和右上角的半径与元素的高度一致(大于也是可以的)。
div{ &nbs p;
height:50px;/*是width的一半*/
width:100px;
background: # 9da;
border-radius:50px 50px 0 0;/*半径至少设置为height的值*/
}
实心圆:
方法:把宽度(width)与高度(height)值设置为一致(也就是正方形),并且四个圆角值都设置为它们值的一半。
如下代码:
div{
height:100px;/*与width设置一致*/
width:100px;
background:#9da;
border-radius:50px;/*四个圆角值都设置为宽度或高度值的一半*/
}
完整代码
<!docty PE ht ML >
<html>
<head>
< ;m eta charset="utf-8">
<t IT le>border-radius</HdhCmsTestdztcsd .COM /title>
<style type="text/css">
div.circle{
height:100px;/*与width设置一致*/
width:100px;
background:#9da;
border-radius:50px;/*四个圆角值都设置为宽度或高度值的一半*/
}
/* 任务 部分*/
div. SEM i-circle{
height:100px;
width:50px;
background:#9da;
border-radius:?;
}
</style>
</head>
<body>
<div class="circle">
</div>
< br />
<!--任务部分-->
<div class="semi-circle">
</div>
</body>
</html>
到此这篇关于border-radius给元素添加圆角边框的方法的 文章 就介绍到这了,更多相关border-radius圆角边框内容请搜索以前的文章或继续浏览下面的相关文章,希望大家以后多多支持!
总结
以上是 为你收集整理的 border-radius给元素添加圆角边框的方法 全部内容,希望文章能够帮你解决 border-radius给元素添加圆角边框的方法 所遇到的问题。
如果觉得 网站内容还不错, 推荐好友。
查看更多关于border-radius给元素添加圆角边框的方法的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did201042