前端 - css如何画一个半圆?
问题描述
我写的demo 在这https://jsfiddle.net/yye46hgy/,怎样才能得到如图的效果呢?(而且不能定宽定高,做成自适应)
问题解答
回答1:分别设置border-radius的水平和垂直半径就行了吧。需要做些数学运算,可以用sass或less。
<style> p {width: 5em;height: 1em;padding: 0.6em 0 0.2em 0;/* 水平半径 = width/2, 垂直半径 = height + padding */border-radius: 2.5em 2.5em 0 0/1.8em 1.8em 0 0;background-color: #f29900;color: #fff;text-align: center;font-size: 1.6rem; }</style><p>立即申请</p>回答2:
https://jsfiddle.net/yye46hgy/2/
回答3:方法1:html
<p class='half-circle'> </p>
css
.half-circle{ width:0px; height:0px; border-width:100px; border-style:solid; border-color:violet violet transparent transparent; background-color:transparent; transform:rotate(-45deg); -webkit-transform:rotate(-45deg); -moz-transform:rotate(-45deg); -ms-transform:rotate(-45deg); -o-transform:rotate(-45deg); border-radius:50%;}
方法2html
<p class='half-circle'> <p class='inner-circle'> </p></p>
css
.half-circle{ width:200px; height:100px; overflow:hidden;}.inner-circle{ width:200px; height:200px; border-radius:50%; background-color:purple;}回答4:
width和height为0border厚度为xx px的盒子
画半圆的思路和三角形差不多
相关文章:
1. python - (初学者)代码运行不起来,求指导,谢谢!2. 为什么python中实例检查推荐使用isinstance而不是type?3. mysql里的大表用mycat做水平拆分,是不是要先手动分好,再配置mycat4. window下mysql中文乱码怎么解决??5. sass - gem install compass 使用淘宝 Ruby 安装失败,出现 4046. html5 - H5 SSE的本质是什么?7. javascript - h5上的手机号默认没有识别8. python - 获取到的数据生成新的mysql表9. python的文件读写问题?10. javascript - js 对中文进行MD5加密和python结果不一样。
