目录

background-image

来设置元素的背景图片,默认值为none,<url>是指背景图片的地址,这个地址可以是相对地址,也可以是绝对地址。

 

语法

background-image: none;
background-image: url(http://www.xxx.com/background-image.png);

描述
none表示无背景的关键字。
<image>图片地址。

例子

HTML

<p>
  There were doors all round the hall, but they were all locked; and whenAlice had been all the way down one side and up the other, trying every door, she walked sadly down the middle, wondering how she was ever to get out again.
</p>

CSS

p {
  background-image: url("https://mdn.mozillademos.org/files/12057/starsolid.gif");
  background-attachment: fixed;
}

执行结果

There were doors all round the hall, but they were all locked; and when Alice had been all the way down one side and up the other, trying every door, she walked sadly down the middle, wondering how she was ever to get out again.

参考

相关链接

外部链接