背景
主要是2个背景属性:
- background-size
- background-origin
您还将学习如何使用多重背景图像。
在 CSS3 之前,背景图片的尺寸是由图片的实际尺寸决定的。在 CSS3 中,可以规定背景图片的尺寸,这就允许我们在不同的环境中重复使用背景图片。
您能够以像素或百分比规定尺寸。如果以百分比规定尺寸,那么尺寸相对于父元素的宽度和高度。
content-box, padding-box,和 border-box 区域内可以放置背景图像。
width: 250px;
height: 250px;
padding: 25px;
background-image: url('images/border.png');
background-repeat: no-repeat;
background-origin: border-box;
}
.background-origin-content {
height: 250px;
padding: 25px;
background-image: url('images/border.png');
background-repeat: no-repeat;
background-position: left;
background-origin: content-box;
}