css背景属性整理

背景颜色 {background-color:red}/*常用十六进制颜色#fff*/

图片 {background-image:url();} /*插入图片路径*/

重复 {background-repeat: no-repeat;}/*设置背景图片不重复*/

滚动 {background-attachment: fixed;}(固定) scroll;(滚动--默认的)

位置 {background-position ;}四种定位方式 

  1单词定位方式:left center right / top center bottom 可以理解为一个九宫格

left top top center right top
left center center center right center
left bottom bottom center right bottom

  2像素定位方式:background-position:10px 50px;  距离左边10像素,距离上边50像素 只有这一种离左离上的规则

  3百分比方式:background-position:10% 20%; 距离左边百分之十,距离上边百分之二十

  4混合方式:background-position:left 100px; 靠左 距离上边100px

简写方法 {background:#000 url(..) repeat fixed left top;} /*按照这个顺序先颜色 图片 平铺 定位 固定*/

猜你喜欢

转载自www.cnblogs.com/lsqbk/p/9919498.html