background的用法

来源:互联网 发布:c语言代码在线运行 编辑:程序博客网 时间:2024/05/29 07:06

更多资源来源于菜鸟教程:http://www.runoob.com/css/css-background.html;

个人对于background的理解:

background属于复合样式(css样式):颜色,url,repeat/no-repeat,是否固定,position(定位);

分别为:background-color,background-image,background-repeat,background-attachment,background-position;

background-image在css3中,可以引入多张图片,对应的background其他的属性都具有多个属性值,例:


css3中background中增加了其他的新属性:background-size,background-Origin(指定背景图像的区域),back-clip(规定背景绘制区域);

background-size:宽度,高度;

background-origin:content-box;该属性有三个值:content-box,padding-box,border-box;

padding-box和border-box实现的效果类似;


content-box实现的效果,占据内容局域:


backgound-clip(规定背景绘制区域): content-box;目前只有content-box和padding-box;


content-box



background-attachment(设置背景图像是否固定或者随着页面的其余部分滚动。)

scroll背景图片随页面的其余部分滚动。这是默认fixed背景图像是固定的inherit指定background-attachment的设置应该从父元素继承


fixed表示固定定位;

原创粉丝点击