CSS笔记(三)背景

  CSS 允许应用纯色作为背景,也允许使用背景图像创建相当复杂的效果。

  参考:http://www.w3school.com.cn/css/css_background.asp

  • 背景色
p {background-color: gray; padding: 20px;}
  • 背景图像
body
  { 
      background-image: url(bg.png);
      background-repeat: repeat-y;
      background-position: center; 
      background-attachment: fixed
  }
属性描述
background 简写属性,作用是将背景属性设置在一个声明中。
background-attachment 背景图像是否固定或者随着页面的其余部分滚动。
background-color 设置元素的背景颜色。
background-image 把图像设置为背景。
background-position 设置背景图像的起始位置。
background-repeat 设置背景图像是否及如何重复。
原文地址:https://www.cnblogs.com/AmitX-moten/p/4846471.html