CSS3

プロパティ

background-color

  編集:2022.07.14 by T.A.

mdn

下塗りの色(背景色)。

名前 background-color
<color>
初期値 transparent
対象 全ての要素
継承 されない
百分率 受容しない
算出値 算出色
アニメーション型 算出値の型による

このプロパティは、要素の 背景色 を設定する。色はどの背景画像よりも背後に描かれる。

<color>
<DIV style="background-color:#888; padding:10px">
 <SPAN style="background-color:yellow">あ  </SPAN><BR>
 <SPAN style="background-color:#ff0">あ  </SPAN><BR>
 <SPAN style="background-color:#ff08">あ  </SPAN><BR>
 <SPAN style="background-color:rgb(255,255,0)">あ  </SPAN><BR>
 <SPAN style="background-color:rgba(255,255,0,0.5)">あ  </SPAN><BR>
</DIV>
あ  
あ  
あ  
あ  
あ  

transparent
透明な黒。
<DIV style="background-color:#888; padding:10px">
 <SPAN style="background-color:yellow">あ  </SPAN><BR>
 <SPAN style="background-color:#ff08">あ  </SPAN><BR>
 <SPAN style="background-color:transparent">あ  </SPAN><BR>
</DIV>
あ  
あ  
あ  

h1{ background-color: #F00 }	/* 背景を赤色に設定する。 */

背景色の塗り区画は、[最も背後の背景画像層]に対応する[background-clip の層値]に則って、外側が切り取られる。


テスト
HTML:

ここに表示
HTML:

ここに表示
スクリプト:


スクリプト:



表示内容:
表示内容: