地图 更多

北大青鸟WEB前端培训:CSS3 圆角

作者:雷老师日期:2019-10-16 09:16浏览89
展开阅读全文

CSS3 圆角

使用 CSS3 border-radius 属性,你可以给任何元素制作 "圆角"。

CSS3 圆角制作器


浏览器支持

表格中的数字表示支持该属性的第一个浏览器的版本号。

-webkit- 或 -moz- 前面的数字表示支持该前缀的第一个版本。

属性          
border-radius 9.0 5.0
4.0 -webkit-
4.0
3.0 -moz-
5.0
3.1 -webkit-
10.5

CSS3 border-radius 属性

使用 CSS3 border-radius 属性,你可以给任何元素制作 "圆角"。

以下为三个实例:

1. 指定背景颜色的元素圆角:

圆角!

2. 指定边框的元素圆角:

圆角!

3. 指定背景图片的元素圆角:

圆角!

代码如下:

实例

#rcorners1 {
    border-radius: 25px;
    background: #8AC007;
    padding: 20px; 
    width: 200px;
    height: 150px; 
}

#rcorners2 {
    border-radius: 25px;
    border: 2px solid #8AC007;
    padding: 20px; 
    width: 200px;
    height: 150px; 
}

#rcorners3 {
    border-radius: 25px;
    background: url(paper.gif);
    background-position: left top;
    background-repeat: repeat;
    padding: 20px; 
    width: 200px;
    height: 150px; 
}

 

CSS3 border-radius - 指定每个圆角

如果你在 border-radius 属性中只指定一个值,那么将生成 4 个 圆角。

但是,如果你要在四个角上一一指定,可以使用以下规则:

  • 四个值: 第一个值为左上角,第二个值为右上角,第三个值为右下角,第四个值为左下角。
  • 三个值: 第一个值为左上角, 第二个值为右上角和左下角,第三个值为右下角
  • 两个值: 第一个值为左上角与右下角,第二个值为右上角与左下角
  • 一个值: 四个圆角值相同

以下为三个实例:

1. 四个值 - border-radius: 15px 50px 30px 5px:

 

2. 三个值 - border-radius: 15px 50px 30px:

 

3. 两个值 - border-radius: 15px 50px:

 

以下为源代码:

实例

#rcorners4 {
    border-radius: 15px 50px 30px 5px;
    background: #8AC007;
    padding: 20px; 
    width: 200px;
    height: 150px; 
}

#rcorners5 {
    border-radius: 15px 50px 30px;
    background: #8AC007;
    padding: 20px; 
    width: 200px;
    height: 150px; 
}

#rcorners6 {
    border-radius: 15px 50px;
    background: #8AC007;
    padding: 20px; 
    width: 200px;
    height: 150px; 
}

您还可以创建椭圆边角:

实例

#rcorners7 {
    border-radius: 50px/15px;
    background: #8AC007;
    padding: 20px; 
    width: 200px;
    height: 150px; 
}

#rcorners8 {
    border-radius: 15px/50px;
    background: #8AC007;
    padding: 20px; 
    width: 200px;
    height: 150px; 
}

#rcorners9 {
    border-radius: 50%;
    background: #8AC007;
    padding: 20px; 
    width: 200px;
    height: 150px;
}
 

作者:雷老师日期:2019-10-16 09:16浏览:89

热点关注

  • 高考如可选学校
  • 高中生学什么好
  • 男生学什么好
  • 女生学什么好
  • 北大青鸟学费多少
  • 北大青鸟怎么样
  • 转行学什么好
  • 大学生学什么好

在线客服

Q Q:2435115494
电话:400-136-0818
手机微信扫一扫
作者:雷老师浏览89
外事校区地址:西安市雁塔区科技西路1105号鱼化龙创客空间     长安校区地址:西安市长安区凤栖原地铁口 D口正对面
版权所有   陕西华美人教育科技有限公司  陕ICP备12006174号     电话:400-136-0818 / 029-63631788