Css盒子模型之background基础

1. 设置背景颜色

 1 { 2 background-color:red; 3 4 } 

2. 设置背景图像

1 {
2 background-image:url("images/two.img");
3 }

3. 设置背景图像平铺

可以用background-repeat属性来控制

  • repeat:水平和竖直方向平铺
  • no-repeat:不平铺
  • repeat-x:沿水平方向平铺
  • repeat-y:沿垂直方向平铺
1 {
2 background-repeat:no-repeat;……
3 }

4. 综合布置元素的背景

1 {
2 background:url(img/html.jpg)  no-repeat  center fixed;
3 }

猜你喜欢

转载自www.cnblogs.com/ONE-PIECE-ZXZ/p/9759572.html