Heim  >  Artikel  >  Web-Frontend  >  CSS3之圆角_html/css_WEB-ITnose

CSS3之圆角_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:51:02941Durchsuche

CSS3圆角border-radius也是比较常用的,有了圆角,可以少很多图片了:)

语法:

border-radius : none | {1,4} [/ {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梦么?就是用了很多圆角绘制的。

 

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn