css3怎么绘制半圆(CSS3,web开发)

时间:2024-05-10 08:08:36 作者 : 石家庄SEO 分类 : web开发
  • TAG :

css3绘制半圆的方法:1、利用border-radius属性实现,只需要将相邻两个角的值设置为宽/高度的一半,另两个角设置为0即可。2、利用css3的clip属性和rect()函数来实现。

本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。

方法1:使用border-radius实现半圆

border-radius属性用于给元素设置圆角边框,可以指定1-4值,为边框创建(1~4个)圆角效果

语法:

border-radius:1-4length|%

每个半径的四个值的顺序是:左上角,右上角,右下角,左下角。如果省略左下角,右上角是相同的。如果省略右下角,左上角是相同的。如果省略右上角,左上角是相同的。

示例:

<!DOCTYPEhtml><html><head><metacharset="UTF-8"><style>*{margin:0;padding:0;}.clearfix{zoom:1;/*为IE6,7的兼容性设置*/}.clearfix:after{content:'.';display:block;height:0;clear:both;visibility:hidden;}ulli{list-style:none;float:left;margin:50px050px20px;text-align:center;}li{background:red;}h3{margin-top:20px;}.circle1{width:100px;height:50px;border-radius:50px50px00;line-height:50px;}.circle2{width:50px;height:100px;border-radius:050px50px0;line-height:100px;}.circle3{width:100px;height:50px;border-radius:00px50px50px;line-height:50px;}.circle4{width:50px;height:100px;border-radius:50px0050px;line-height:100px;}.circle5{width:100px;height:100px;border-radius:50px;line-height:100px;}</style></head><body><div><h3>用border-radius实现半圆</h3><ul><li>上边圆</li><li>左边圆</li><li>下边圆</li><li>左边圆</li><li>全圆</li></ul></div></body></html>

效果图:

css3怎么绘制半圆

方法2:使用css3的clip 方法剪裁实现半圆

clip 属性剪裁绝对定位元素。也就是说,只有 position:absolute 的时候才是生效的。唯一合法的形状值是:rect (top, right, bottom, left)

示例:

<!DOCTYPEhtml><html><head><metacharset="UTF-8"><style>.clearfix{zoom:1;/*为IE6,7的兼容性设置*/}ulli{list-style:none;float:left;margin:50px050px20px;text-align:center;}li{background:red;}h3{margin-top:20px;}.demo{/*左半圆*/position:absolute;/*clip属性剪裁绝对定位元素。也就是说,只有position:absolute的时候才是生效的。*/width:100px;height:100px;border-radius:50px;/*line-height:50px;*/clip:rect(0px50px100px0px);/*唯一合法的形状值是:rect(top,right,bottom,left)*/}.right-circle{/*右半圆*/left:200px;clip:rect(0px100px100px50px);/*唯一合法的形状值是:rect(top,right,bottom,left)*/}</style></head><body><div><h3>css3的clip方法剪裁实现半圆</h3><pstyle="color:red;"></p><ulstyle="position:relative;"><li>左半圆</li><liclass="demoright-circle">右半圆</li><li></li></ul></div></body></html>

效果图:

css3怎么绘制半圆

 </div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:css3怎么绘制半圆的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:php的文件怎么转base64下一篇:

8 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18