css背景主要包括五个属性:
background-color
background-color:transparent ||
用来设置元素的背景颜色,默认值为transparent(透明),可用颜色名,RGB色,hls值,十六进制值指定颜色。
background-image
background-image:none ||
用来设置元素的背景图片,默认值为none,可以用相对地址,也可以用绝对地址。
background-repeat
background-repeat:repeat || repeat-x || repeat-y || no-repeat
用来设置元素背景图片在元素盒模型中的铺放方式,默认值为repeat,往X轴与Y轴方向同时平铺,repeat-x只x轴方向平铺,repeat-y只y轴反向平铺,no-repeat不平铺。
background-attachment
background-attachment:scroll || fixed
用来设置元素背景图片是否固定。默认值为scroll,不固定。fixed,固定。
background-position
background-position: || || [left | center | right] [,top | center | bottom]
用来设置元素背景图片的位置,默认值为(0,0) || (0%,0%) || (left top),其值可以是具体的百分数或数值,也可以使用关键词。
在css3中,又新增了4个属性。
background-origin
background-origin属性主要用来决定background-position属性的参考原点,即决定背景图片定位的起点。
background-origin:padding-box || border-box || content-box
在浏览器的老版本中,属性值分别为padding,border,content。
padding-box(padding):默认值,决定background-position起始位置从padding的外边缘开始显示背景图片。
border-box(border):决定background-position起始位置从border的外边缘开始显示背景图片。
content-box(content):决定background-position其实位置从content的外边缘开始显示背景图片。
div{ width: 100px; height: 100px; border:10px dashed; padding:10px; background:url(https://img.alicdn.com/imgextra/i4/2406102577/TB2t7IWdFXXXXaqXpXXXXXXXXXX_!!2406102577.jpg) no-repeat scroll 0 0; background-origin:padding-box; }
查看更多关于css3背景记_html/css_WEB-ITnose的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did108632