最简介的写法
body
{
background: #00FF00 url(bgimage.gif) no-repeat fixed top;
}
inherit 属性将继承父类该属性
background对应的属性分别有:
- background-attachment :
值 | 作用 |
---|---|
scroll | 随页面滚动而滚动 |
fixed | 不随页面滚动 |
- background-color
body {background-color: yellow}
h1 {background-color: #00ff00}
h2 {background-color: transparent}
p {background-color: rgb(250,0,255)}
- background-image
body
{
background-image: url(bgimage.gif);
}
- background-position
top left
top center
top right
center left
center center
center right
bottom left
bottom center
bottom right
x% y% 水平位置和垂直位置,左上角是0% 0%默认是50%
xpos ypos 水平位置和垂直位置,左上角是0 0 ,默认是50%
- background-repeat
值 | 作用 |
---|---|
repeat | 默认。背景图像将在垂直方向和水平方向重复。 |
repeat-x | 背景图像将在水平方向重复。 |
repeat-y | 背景图像将在垂直方向重复。 |
no-repeat | 背景图像将仅显示一次。 |