Visit Mozilla.org

CSS:background-image

From MDC

« CSS 参考

[编辑] 摘要

The background-image property sets the background image for an element.

  • 初始值: none
  • 应用于: 所有元素
  • 继承性:无
  • 百分数: N/A
  • 媒体: visual
  • Computed value: absolute URI or none

[编辑] 语法

background-image: uri | none | inherit

[编辑]

uri 
The location of the image resource to be used as a background image.
none 
Used to specify that an element is to have no background image.

[编辑] 例子

View Live Examples

body { background-image: url("images/darkpattern.png"); }

p { background-image: none; }

[编辑] 提示

Developers should ensure that they specify a background-color to be used if an image is not available. Background images are rendered on top of the background color.

[编辑] 规范

[编辑] 浏览器兼容性

Browser Lowest Version
Internet Explorer 4
Firefox 1
Netscape 4
Opera 3.5

[编辑] 参见

background, background-attachment, background-color, background-image, background-position, background-repeat