目录

background-image

描述 (Description)

background-image定义指向要放置在元素背景中的图像资源的指针。

可能的值 (Possible Values)

  • uri - 图像的URL。

  • none - 将background-image设置为none表示不应将背景图像用于匹配元素。

  • transparent

适用于 (Applies to)

所有HTML元素。

DOM语法 (DOM Syntax)

object.style.backgroundImage = "Any value as defined above";

例子 (Example)

以下是演示如何设置元素的背景图像的示例。

<html>
   <head>
      <style>
         body {
            background-image: url("/css/images/css.jpg");
            background-color: #cccccc;
         }
      </style>
   </head>
   <body>
      <h1>Hello World!</h1>
   </body>
<html>

它会产生以下结果 -

新页面打开
↑回到顶部↑
WIKI教程 @2018