css實現橢圓


先實現個簡單點的,用css實現一個圓,ok,直接上代碼:

.circle{
    width: 100px;
    height:100px;
    background: red;
    border-radius: 50%;
}

circle

實現橢圓的方法

1.利用css3變形

.circle{
    width: 100px;
    height:100px;
    background: red;
    border-radius: 50%;
    transform: scale(1,0.5);
}

效果如下
circle

2.直接改變高度

.circle{
    width: 100px;
    height:50px;
    background: red;
    border-radius: 50%;
}

效果如下
circle

3.利用border-radius屬性

.circle{
    width: 100px;
    height:100px;
    background: red;
    border-top-left-radius:100px 50px;
    border-top-right-radius:100px 50px;
    border-bottom-left-radius:100px 50px;
    border-bottom-right-radius:100px 50px;
}

效果如下
circle
但是這樣實現的效果還不是橢圓,還要再把高度設置為寬度的一半,所以還是直接用第二種方法比較簡便

參考


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM