サイト内検索
...スタイルシート(css)...
スタイルシート・ボックス
背景色(background-color)
- 背景色は、background-colorプロパティを指定します。
- ページ全体に背景色を設定する使い方
- body{background-color: #888888;}
- [使い方]
- .sample{background-color: #ffcccc;}
プロパティ名 | 値
(サンプル) |
説明 |
---|---|---|
background-color: | ; |
16進数RGB値(例・・#fff000)
または カラーネーム(例・・red)を指定します。 |
transparent; | transparent「透明」を指定したことになります。
(初期値) |
サンプル
[headの中]
<style type="text/css"><!--
.sample1{
background-color:#ffcccc; color:#000000;
width: 450px;
}
.sample2{
background-color:#ffff8e; color:#ffa500;
width: 450px;
}
.sample3{
background-color:#ccff99; color:#40a52b;
}
-->
</style>
[bodyの中]
<div class="sample1">背景色は、ピンク</div>
<div class="sample1">背景色は、ピンク
<span class="sample2">文字は、オレンジ</span>
<span class="sample3">文字は、緑</span>
</div>
[ブラウザ上]
背景色は、ピンク
背景色は、ピンク
文字は、オレンジ・文字は、緑
文字は、オレンジ・文字は、緑