在css中将图像作为网页元素的背景可以通过什么属性

html-css06

在css中将图像作为网页元素的背景可以通过什么属性,第1张

定义和用法

background 简写属性在一个声明中设置所有的背景属性。

可以设置如下属性:

background-color

background-position

background-size

background-repeat

background-origin

background-clip

background-attachment

background-image

如果不设置其中的某个值,也不会出问题,比如 background:#ff0000 url('smiley.gif')也是允许的。

通常建议使用这个属性,而不是分别使用单个属性,因为这个属性在较老的浏览器中能够得到更好的支持,而且需要键入的字母也更少。

默认值:

not specified    

继承性:

no    

版本:

CSS1 + CSS3    

JavaScript 语法:

object.style.background="white url(paper.gif) repeat-y"    

实例

如何在一个声明中设置所有背景属性:

body

 {

 background: #00FF00 url(bgimage.gif) no-repeat fixed top

 }

很高兴为你解答:

body {

margin-left: 0px

margin-top: 0px

margin-right: 0px

margin-bottom: 0px

background-image: url(images/ld_05.jpg)

}

括号里的内容是路径和图片的名称。

希望我的回答对你有帮助。