さまざまな要素の背景色を設定す...ログイン

さまざまな要素の背景色を設定する

この例では、次のことを示します。

h1、p、div 要素にそれぞれ異なる背景色を設定します。

分析例:

h1{background-color :#6495ed;}

p{背景色:#e0ffff; }

div{背景色:#b0c4de;}

要素セレクター h1{}、p{}、div{} を使用して HTML 内の h1、p、div 要素をそれぞれ選択し、{} の background-color 属性を使用して背景色を設定します


次のセクション
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> <style> h1 { background-color:#6495ed; } p { background-color:#e0ffff; } div { background-color:#b0c4de; } </style> </head> <body> <h1>CSS background-color 实例!</h1> <div> 该文本插入在 div 元素中。 <p>该段落有自己的背景颜色。</p> 我们仍然在同一个 div 中。 </div> </body> </html>
コースウェア