背景样式

1.背景色:background-color

background-color:背景颜色属性,就像颜色属性背景颜色指定的是背景颜色。
5种定义颜色的方法:
Property Value            Description
Color:<color keyword>     设置颜色为给定的值
Color:#rrggbb             用HTML的16位进制来表示
Color:rgb(rrr,ggg,bbb)    制定RGB三种颜色的数值(0-255)
Color:rgb(rrr%,ggg%,bbb%) 通过RGB三种颜色的百分比指定
Color:inherit             继承父值

2.背景图片:background-image

在Css中,你可以对任何元素指定背景图片,规则如下:
   Property               Value
background-image: url("<location>")
background-image: none
background-image: inherit

3.背景重复:
你可以对背景显示的方式进行微调,通过background-repeat属性,你可以指定背景的重复方式。
下面的规则是在说背景图片不允许重复:
.body
{
 background-image: url(Images/title.jpg);
 background-repeat:no-repeat;
}
如果不指定background-repeat:no-repeat,默认情况下是允许重复的。

下面是不同的选择规则:
            Property  Value
 background-repeat:  repeat
 background-repeat:  repeat-x
 background-repeat:  repeat-y
 background-repeat:  no-repeat
 background-repeat:  inherit

4.背景附着:background-attachment

这个background-attachment属性可以控制背景是否随网页滚动。
以下为几个常见值:
         Property     Value
background-attachment:scroll;
background-attachment:fixed;
background-attachment:inherit;

5.背景定位:background-position

背景定位属性用来指定背景图片在网页的展示位置。比如:
body
{
background-image: url(Images/title.jpg);
background-position: 10% 10%;
}
规则很简单
            Property  Value                     Notes
background-position: <x><y>                   用具体数值或者百分比指定
background-position: [top \center\ bottom]    用关键字定位
                                [left \ center\ right]  

原文地址:https://www.cnblogs.com/yuyu/p/1776458.html