前端 - css如何畫一個半圓?
問題描述
我寫的demo 在這https://jsfiddle.net/yye46hgy/,怎樣才能得到如圖的效果呢?(而且不能定寬定高,做成自適應(yīng))
問題解答
回答1:分別設(shè)置border-radius的水平和垂直半徑就行了吧。需要做些數(shù)學(xué)運算,可以用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的盒子
畫半圓的思路和三角形差不多
相關(guān)文章:
1. java - 部署web項目時無法省略項目名?2. python - [已解決]flask QQ郵箱mail3. mysql 5個left關(guān)鍵 然后再用搜索條件 幾千條數(shù)據(jù)就會卡,如何解決呢4. javascript - position fixed;設(shè)置了height 100 卻不是瀏覽器可視窗口的寬高,求大神釋疑。5. mysql - 在不允許改動數(shù)據(jù)表的情況下,如何優(yōu)化以varchar格式存儲的時間的比較?6. html - eclipse 標簽錯誤7. 主題切換問題,用過別人的webapp在后臺切換模板主題后手機端打開網(wǎng)頁就是切換到的主題了8. python3.x - git bash如何運行.bat文件?9. javascript - vue-cli proxyTable怎么配置10. java - 如何寫一個intellij-idea插件,實現(xiàn)編譯時修改源代碼的目的
