Dreamweaver 教程-CSS背景属性(background)
资源介绍
1.背景颜色属性(background-color)
body { background-color:red ;}
2.背景图片(background-image)
body { background-image:url(http://www.xiazaiba.com/images/logo.gif);}
如你所见,默认情况下背景图片会不断重复,直到布满整个网页,下面我们来看看如何用CSS控制背景图片的重复。
3.背景图片的重复设置(background-repeat)
(1)不重复
body { background-image:url(http://www.xiazaiba.com/images/logo.gif); background-repeat:no-repeat; }
(2)水平方向重复
body { background-image:url(http://www.xiazaibaba.com/images/logo.gif); background-repeat:repeat-x;}
(3)垂直方向重复
body { background-image:url(http://www.xiazaiba.com/images/logo.gif); background-repeat:repeat-y;}
4.背景图片位置(background-position)
body { background-image:url(http://www.xiazaiba.com/images/logo.gif); background-position:center; background-repeat:no-repeat;}
5.将背景图片固定在某个位置(background-attachment)
该属性可以定义背景图片是否随着滚动条的滚动而改变位置。
body { background-image:url(http://www.xiazaiba.com/images/logo.gif); background-attachment:fixed; background-repeat:no-repeat }