Podsumowanie
background-color ustawia kolor tła dla elementu, poprzez wartość koloru lub słowo kluczowe transparent.
| Wartość początkowa | transparent |
|---|---|
| Stosowana do | wszystkich elementów. It also applies to ::first-letter and ::first-line. |
| Dziedziczona | no |
| Media | visual |
| Wartość wyliczona | If the value is translucent, the computed value will be the rgba() corresponding one. If it isn't, it will be the rgb() corresponding one. The transparent keyword maps to rgba(0,0,0,0). |
| Animatable | yes, as a color |
| Canonical order | the unique non-ambiguous order defined by the formal grammar |
Składnia
background-color: color | transparent | inherit
Wartości
- color
- Kolor może być określony jako szesnastkowa wartość RGB, normalna wartość RGB lub poprzez użycie jednego z predefiniowanych słów kluczowych określających kolor.
- transparent
- Domyślną wartością dla
background-colorjesttransparent, co oznacza, że element nie ma własnego koloru tła, zamiast tego pokazując kolor tła elementu znajdującego się z tyłu.
Przykłady
HTML
<div class="exampleone"> Lorem ipsum dolor sit amet, consectetuer </div> <div class="exampletwo"> Lorem ipsum dolor sit amet, consectetuer </div> <div class="examplethree"> Lorem ipsum dolor sit amet, consectetuer </div>
CSS
.exampleone {
background-color: teal;
color: white;
}
.exampletwo {
background-color: rgb(153,102,153);
color: rgb(255,255,204);
}
.examplethree {
background-color: #777799;
color: #FFFFFF;
}