CSS3之圓角

來源:互聯網
上載者:User

標籤:

CSS3圓角border-radius也是比較常用的,有了圓角,可以少很多圖片了:)

文法:

border-radius : none | <length>{1,4} [/ <length>{1,4} ]?

說明:length不可為負值。border-radius是一種縮寫方法。如果“/”前後的值都存在,那麼“/”前面的值設定其水平半徑,“/”後面值設定其垂直半徑。如果沒有“/”,則水平和垂直半徑相等。另外其四個值是按照top-left、top-right、bottom-right、bottom-left的順序來設定的。

一個簡單的例子:

<!DOCTYPE html><html><head><style> #radius{text-align:center;border:2px solid #a1a1a1;padding:10px 40px; background:#dddddd;width:350px;height:200px;border-radius:25px;-moz-border-radius:25px; }</style></head><body><div id="radius">Border-Radius</div></body></html>                      

圖:

設定兩個值時,對角的值相同,top-left和bottom-right取第一個值,另外兩個角取另一個值。

<!DOCTYPE html><html><head><style> #radius{text-align:center;border:2px solid #a1a1a1;padding:10px 40px; background:#dddddd;width:350px;height:200px;border-radius:25px 50px;-moz-border-radius:25px 50px; }</style></head><body><div id="radius">Border-Radius</div></body></html>                      

效果:

另外還可以分別設定每個角的水平和垂直半徑:

border-radius:15px 30px / 20px 10px;

等價於:

border-top-left-radius:15px 20px;border-bottom-right-radius:15px 20px;border-top-right-radius:30px 10px;border-bottom-left-radius: 30px 10px;

效果:

另外,當圓角半徑小於等於邊框厚度時,內圓角會是方形的,這也很好理解,例如:

border:20px solid #a1a1a1;border-radius:20px;

效果:

當圓角半徑大於邊框厚度時,邊框內部也會呈現圓角效果:

border:10px solid #a1a1a1;border-radius:20px;

效果:

可以利用圓角繪製圓形:

<!DOCTYPE html><html><head><style> #radius{text-align:center;margin:50px auto;width:0;height:0;border:100px solid #a1a1a1;border-radius:100px;}</style></head><body><div id="radius"></div></body></html>                      

效果:

還記得那個CSS3的哆啦A夢嗎?就是用了很多圓角繪製的。

 

CSS3之圓角

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.