详解CSS3中的border-radius样式

border-radius是CSS3中诞生的新样式,它可以使边框的边角变成弧形和圆角。以往制作按钮、弧形边框时需要使用背景切图的方式实现;不但臃肿,而且还容易产生布局BUG,不适于自适应框架的书写。

1.首先介绍一下语法:

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

<length>:用长度值设置对象的圆角半径长度;不允许负值。

<percentage>:用百分比设置对象的圆角半径长度;不允许负值。

 

2.说明一下:

第一个值是水平半径。

如果第二个值省略,则它等于第一个值,这时这个角就是一个四分之一圆角。

如果第二个值为任意值,则会改变圆角的弧度,具体效果下面会举例进行演示

如果任意一个值为0,则这个角是矩形,不会是圆的。

当然,此值不允许是负值。

 

3.CSS3适用的浏览器:

IE9.0、Firefox、Safari、Chrome、Opera

 

4.CSS3测试实例:

水平与垂直半径相同时:

 


  • 提供1个参数
    border-radius:10px;
  • 提供2个参数
    border-radius:10px 20px;
  • 提供3个参数
    border-radius:10px 20px 30px;
  • 提供4个参数
    border-radius:10px 20px 30px 40px;

     

 

水平与垂直半径不同时:

 


  • 提供1个参数
    border-radius:10px/5px;
  • 提供2个参数
    border-radius:10px 20px/5px 10px;
  • 提供3个参数
    border-radius:10px 20px 30px/5px 10px 15px;
  • 提供4个参数
    border-radius:10px 20px 30px 40px/5px 10px 15px 20px

     

 

除了以上的几种表达方式以外,还可以指定某个角生成弧形样式。

左上角圆角:border-radius-topleft : 10px

右上角圆角:border-radius-topright: 10px

左下角圆角:border-radius-bottomleft : 10px

右下角圆角:border-radius-bottomright : 10px

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
border-radius是一个CSS属性,用于设置元素的边框的圆角半径。它可以通过指定一个值来设置所有四个角的圆角半径,也可以通过指定四个值来分别设置每个角的圆角半径。\[1\]border-radius属性实际上是border-top-left-radiusborder-top-right-radiusborder-bottom-right-radiusborder-bottom-left-radius四个属性的简写形式。\[3\]例如,border-radius: 30px;表示所有四个角的圆角半径都是30像素。\[2\]如果想要分别设置每个角的圆角半径,可以使用border-top-left-radiusborder-top-right-radiusborder-bottom-right-radiusborder-bottom-left-radius这四个属性。 #### 引用[.reference_title] - *1* [CSS3圆角详解](https://blog.csdn.net/weixin_42659625/article/details/81085841)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [border-radius(CSS3属性)](https://blog.csdn.net/qq_43812504/article/details/110850778)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [CSS3 border-radius 属性](https://blog.csdn.net/qq_38436939/article/details/83830427)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值