前端开发那些事儿

CSS3 新增属性:背景

2021-07-06  本文已影响0人  前小小

background-image

CSS3 中可以通过 background-image 属性添加背景图片。

语法:

background-image:<bg-image> [ , <bg-image> ]*
<bg-image> = none | <url>| <linear-gradient> | <radial-gradient> | <repeating-linear-gradient> | <repeating-radial-gradient>

取值:

示例:

#example1 { 
    background-image: url(img_flwr.gif), url(paper.gif); 
    background-position: right bottom, left top; 
    background-repeat: no-repeat, repeat; 
}

background-size

background-size 指定背景图像的大小。

语法:

background-size: length percentage cover contain;

取值:

示例:重置背景图像

div{
    background:url(img_flwr.gif);
    background-size:80px 60px;
    background-repeat:no-repeat;
}

background-origin

background-origin 属性指定了背景图像的位置区域。

语法:

background-origin: padding-box border-box content-box;

取值:

示例:在 content-box 中定位背景图片

div {
    background:url(img_flwr.gif);
    background-repeat:no-repeat;
    background-size:100% 100%;
    background-origin:content-box;
}

background-clip

CSS3 中 background-clip 背景剪裁属性是从指定位置开始绘制。

语法:

background-clip: border-box padding-box content-box;

取值:

示例:

div {
    background-color:yellow;
    background-clip:content-box;
}
上一篇 下一篇

猜你喜欢

热点阅读