栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > Html/CSS > CSS教程

一篇文章带你了解CSS3圆角知识

CSS教程 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

一篇文章带你了解CSS3圆角知识

一、浏览器支持

表中的数字指定完全支持该属性的第一个浏览器版本。

数字后面的 -webkit- 或者 -moz- 使用时需要指定前缀。

属性ChromeFirefoxSafariOperaIEborder-radius5.0 4.0 -webkit-9.04.0 3.0 -moz-5.0 3.1 -webkit-10.5


二、border-radius 属性1. 创建具有背景图的圆角

CSS3中,可以使用border-radius属性,为元素指定圆角显示。

代码如下:


    
    
    项目

    
        
            #rcorners1 {                border-radius: 25px;                background: #f00;                padding: 20px;                width: 200px;                height: 150px;
            }            #rcorners2 {                border-radius: 25px;                border: 2px solid #73AD21;                padding: 20px;                width: 200px;                height: 150px;
            }            #rcorners3 {                border-radius: 25px;                background: url(img/fy_indexBg.jpg);                background-position: left top;                background-repeat: repeat;                padding: 20px;                width: 200px;                height: 150px;
            }
    

    

        

The border-radius property allows you to add rounded corners to elements.

        

Rounded corners for an element with a specified background color:

                 Rounded corners!

        

Rounded corners for an element with a border:

                 Rounded corners!

                 

Rounded corners for an element with a background image:

        Rounded corners!

    



提示:

border-radius属性实际是border-top-left-radius, border-top-right-radius, border-bottom-right-radius 和 border-bottom-left-radius 属性的简写。


2. 为每个角指定弧度

如果只为border-radius属性指定一个值,则此半径将应用于所有4个角。

另外可以根据自己开发的需求,分别指定每个角。以下是规则:

四个值: 第一个值适用于左上角,第二个值适用于右上方,第三值应用于右下角,第四值适用于左下角。

三个值: 第一个值适用于左上,二值适用于右上和左下,右下第三值适用于。

两个值: 第一个值适用于左上和右下角,和二值适用于右上和左下角。

一个值: 所有的四个角都是圆的。

实例1:

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

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



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

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



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

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



完整代码 :


  
  项目
  
  #rcorners4 {      border-radius: 15px 50px 30px 5px;      background: #f00;      padding: 20px;      width: 200px;      height: 150px;
  }  #rcorners5 {      border-radius: 15px 50px 30px;      background: #f00;      padding: 20px;      width: 200px;      height: 150px;
  }  #rcorners6 {      border-radius: 15px 50px;      background: #f00;      padding: 20px;      width: 200px;      height: 150px;
  }

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

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

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

实例2:

创建椭圆形的圆角

创建椭圆形的圆角

椭圆边框 :border-radius: 50px/15px

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



椭圆边框 : border-radius: 15px/50px

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



椭圆边框 : border-radius: 50%

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



完整代码:


  
  项目
  
    #rcorners7 {        border-radius: 50px/15px;        background: #73AD21;        padding: 20px;        width: 200px;        height: 150px;
    }    #rcorners8 {        border-radius: 15px/50px;        background: #73AD21;        padding: 20px;        width: 200px;        height: 150px;
    }    #rcorners9 {        border-radius: 50%;        background: #73AD21;        padding: 20px;        width: 200px;        height: 150px;
    }

  

椭圆边框 - border-radius: 50px/15px:

  

  

椭圆边框 - border-radius: 15px/50px:

  

  

椭圆边框 - border-radius: 50%:

  

-->
三、总结

1、本文主要讲解了CSS3圆角,通过一些属性的演示,丰富的案例,帮助大家理解CSS知识。希望大家可以耐心的去学习,同时希望碰到问题主动搜索,尝试一下,总会有解决方法。

2、代码很简单,希望能帮到你。


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/242070.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号