前端 - 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. javascript - 关于<a>元素与<input>元素的JS事件运行问题2. css3 - 纯css实现点击特效3. MySQL中的enum类型有什么优点?4. android下css3动画非常卡,GPU也不差啊5. java - 为什么第一个线程已经释放了锁,第二个线程却不行?6. mysql - 记得以前在哪里看过一个估算时间的网站7. javascript - 如何将一个div始终固定在某个位置;无论屏幕和分辨率怎么变化;div位置始终不变8. 大家好,我想请问一下怎么做搜索栏能够搜索到自己网站的内容。9. php - 微信开发验证服务器有效性10. mysql - 查询字段做了索引为什么不起效,还有查询一个月的时候数据都是全部出来的,如果分拆3次的话就没问题,为什么呢。
