EN
이 콘텐츠는 한국어로 제공되지 않아 영어 버전으로 표시됩니다.

background-color property

Specifies the color behind the content of the object.

CSS Backgrounds and Borders Module Level 3, Section 3.2CSS 2.1, Section 5.3.2

Syntax

background-color: transparent | <color>

Property values

One of the following values:

transparent

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

color

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

CSS information

Applies ToAll elements
Mediavisual
Inheritedno
Initial Valuetransparent

Standards information

Remarks

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

Examples

This example uses background-color and background-image 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:

An image showing three div objects with the same width and height but different background-color and background-image settings.

See also

CSSStyleDeclaration
currentStyle
defaults
runtimeStyle
style

 

 

표시:
© 2014 Microsoft. All rights reserved.