Border-radius:使用CSS创建圆角

Border-radius是CSS3新增的属性,是Border的子属性。一直喜爱鼓捣CSS的我,免不了动手尝试,不过每次尝试后就把那些自己处理过代码丢在硬盘里,那天有兴趣了,再去网上找资料,这次心想不如把自己在学习中的心得和大家分享出来。但想系统的把自己对某件事务的理解和认识写出来是件很不容易的事情,毕竟我还没有达到那种境界。

我每次在写教程之类时总担心那一步写的不详细,让读者不明白,所以文章总是臭长。臭长就臭长吧,没有写出来我心里还总觉得遗憾,哈哈~。

提示:目前还没有浏览器支持border-radius属性,只能使用个别浏览器的私有属性
例如:-moz-border-radius: 1em; -webkit-border-radius: 1em;

border-radius的值:

<length>{1,4} [ / <length>{1,4} ]?

例1:

border-radius: 4em;

同等于:

border-top-left-radius:     4em;
border-top-right-radius:    4em;
border-bottom-right-radius: 4em;
border-bottom-left-radius:  4em;

例2:

border-radius: 2em 1em 4em / 0.5em 3em;

同等于:

border-top-left-radius:     2em 0.5em;
border-top-right-radius:    1em 3em;
border-bottom-right-radius: 4em 0.5em;
border-bottom-left-radius:  1em 3em;

例3

<div style="background-color: rgb(102, 204, 51); border: 2px solid #000; -moz-border-radius: 1em; -webkit-border-radius: 1em; border-radius: 1em; width: 6em; height: 6em;" ></div>

例3显示效果如下:

各个浏览器的表现还不同,我在Win XP SP3环境下:Forefox2.0.0、Forefox3.5.2、Chrome2.0.172.39,Safari3.2.1做了比较,看补图。

border-radius

要更深入的了解和认识,就需要不断尝试

例4

<div style="background-color: rgb(102, 204, 51);border: 2px solid rgb(0, 0, 0); -moz-border-radius-topleft: 10px;-webkit-border-top-right-radius: 10px; width: 6em; height: 6em;"></div>

例4显示效果如下:

例5

<div style="background-color: rgb(102, 204, 51);border: 2px solid rgb(0, 0, 0); -moz-border-radius-bottomleft: 10px;-webkit-border-bottom-left-radius: 10px; width: 6em; height: 6em;"></div>

例5显示效果如下:

border-radius同等

-moz-border-radius / -webkit-border-radius

border-top-left-radius同等

-moz-border-radius-topleft / -webkit-border-top-left-radius

border-top-right-radius同等

-moz-border-radius-topright / -webkit-border-top-right-radius

border-bottom-right-radius同等

-moz-border-radius-bottomleft / -webkit-border-bottom-left-radius

border-bottom-left-radius同等

-moz-border-radius-bottomright / -webkit-border-bottom-right-radius

相关参考:

http://www.w3.org/TR/2008/WD-css3-background-20080910/#border-radius
http://www.css3.info/preview/rounded-border/
https://developer.mozilla.org/en/CSS/-moz-border-radius

附件大小
Web-browser-CSS3-border-radius.png7.22 KB

评论

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 允许HTML标签:<a> <img> <em> <del> <strong> <cite> <code> <pre> <ul> <ol> <li> <dl> <dt> <dd> <h3> <h4> <h5> <h6>
  • 自动断行和分段。
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.