圆角是做网页永远绕不过的话题,以前基本是通过背景图片做的,有了CSS3后可以使用简单的属性搞定,可以通过border-radius设置元素的圆角半径。
border-radius: 5px;
对于正方形border-radius设置为边长的一半,就变成圆了。
width: 100px;
height: 100px;
border-radius: 50px;
border-radius是缩写格式,其实border-radius和border属性一样,还可以把各个角单独拆分出来,也就是以下四种写法 :
border-top-left-radius: <length> <length>
border-top-right-radius: <length> <length>
border-bottom-right-radius:<length> <length>
border-bottom-left-radius:<length> <length>
属性值中第一个值是圆角水平半径,第二个值是圆角垂直半径,如果第二个值省略,那么其等于第一个值,这时这个角就是一个四分之一的圆角,如果任意一个值为0,那么这个角就不是圆角。
边框都是线条略显单调,使用CSS3的border-image属性可以用图片作为边框的修饰。
border-image 属性是一个简写属性,用于设置以下属性:
border-image-source // 用在边框的图片的路径。
border-image-slice // 图片边框向内偏移。
border-image-width // 图片边框的宽度。
border-image-outset // 边框图像区域超出边框的量。
border-image-repeat // 图像边框是否应平铺(repeated)、铺满(rounded)或拉伸(stretched)。
box-shadow 属性向框添加一个或多个阴影。
box-shadow:inset x-offset y-offset blur-radius spread-radius color
box-shadow属性至多有6个参数设置:
box-shadow可以使用一个或多个投影,如果使用多个投影时必须需要用逗号分开。
box-shadow: 3px 3px 3px orange, 3px 3px 3px red;
传统的盒模型width就是指内容区域宽度,和padding、border没有关系。但是这在布局上会带来一定的困难。
box-sizing可以改变盒模型:
content-box:标准盒模型
border-box:width = content width + paddingLeft + borderLeft + paddingRight + borderRight
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有