使用 CSS 設定背景色


要使用 CSS 設定背景色,請使用 background-color 屬性。

示例

我們現在來看一個示例 -

 線上演示

<!DOCTYPE html>
<html>
<head>
<style>
.demo {
   text-decoration: overline underline;
   background-color: red;
}
</style>
</head>
<body>
<h1>Details</h1>
<p class="demo">Examination Center near ABC College.</p>
<p class="demo2">Exam begins at 9AM.</p>
</body>
</html>

輸出

示例

我們現在來看另一個示例 -

 線上演示

<!DOCTYPE html>
<html>
<head>
<style>
.demo {
   text-decoration: overline underline;
}
</style>
</head>
<body style="background-color: orange;color: white;">
<h1>Details</h1>
<p class="demo">Examination Center near ABC College.</p>
<p class="demo2">Exam begins at 9AM.</p>
</body>
</html>

輸出

更新於:2019-12-30

161 次瀏覽

開啟您的 職業生涯

透過完成課程獲得認證

開始
廣告