共用方式為


backgroundColor property

Specifies the color behind the content of the object.

 

Syntax

Integer value = object.put_backgroundColor(Variant v);Integer value = object.get_backgroundColor(Variant* sColor);

Property values

Type: VARIANT

One of the following values:

transparent (transparent)

Initial value. Color of the next parent object through which the background is visible.

color (color)

Any valid color value, including those specified in the Color Table.

String format

transparent | <color>

CSS information

Applies To All elements
Media visual
Inherited no
Initial Value transparent

Standards information

Remarks

This property can be set with the other background properties by using the IHTMLRuleStyle::background composite property.

As of Internet Explorer for Windows Phone 8.1 Update, Internet Explorer for Windows Phone supports "-webkit-background-color" as an alias for this property.

Examples

This example uses IHTMLCurrentStyle::backgroundColor and IHTMLCurrentStyle::backgroundImage to create three div objects with the same width and height but different background colors and images.

div {
  width: 150px;
  height: 150px;
  background-repeat: no-repeat;
  background-position: 50% 50%;
  float: left;
  margin-right: 10px;
}
.circle {
  background-color: aqua;
  background-image: url(circle.png);
}
.square {
  background-color: aquamarine;
  background-image: url(square.png);
}
.triangle {
  background-color: bisque;
  background-image: url(triangle.png);
}
<body>
   <div class="circle"></div>
   <div class="square"></div>
   <div class="triangle"></div>
</body>

The following image shows the result:

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

Mshtml.h

IDL

Mshtml.idl

DLL

Mshtml.dll