當前位置:軟件學(xué)堂 > 資訊首頁 > 網(wǎng)絡(luò)編程 > DIV+CSS > CSS背景顏色background-color

CSS背景顏色background-color

2012/11/24 13:12:26作者:佚名來源:網(wǎng)絡(luò)

移動端

【實例介紹】

CSS背景顏色background-color

在HTML中.設(shè)置網(wǎng)頁的背景顏色利用的是<body>標簽中的bacolor屬性,而在CSS中不但可以設(shè)置網(wǎng)頁的背景顏色,還可以設(shè)置文字的背景顏色。在CSS中,背景顏色使用background-color屬性來設(shè)置。

【基本語法】

background-color:顏色取值

【語法介紹】

其中顏色值可以使用顏色名稱,也可以使用十六進制的顏色代碼。

【實例代碼】

<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>無標題文檔</title> </head> <style type="text/css"> .bj {  font-size: 13px;  line-height: 20px;  background-color: #0C3; } </style> <body> <table width="500" border="0" cellspacing="0" cellpadding="0">   <tr>     <td class="bj">哭泣不是誰都有的權(quán)利<br />       不是每一個人都有權(quán)利流淚<br />     也許是故作的堅強。<br /></td>   </tr> </table> </body> </html>

【代碼分析】

代碼中的background-color.#0C3設(shè)置背景顏色為#0c3,在瀏覽器中預(yù)覽效果,如圖所示。background—color屬性可以用于各種網(wǎng)頁元素,這里是對單元格應(yīng)用的屬性。

背景顏色background-color運行效果

 【素材及源碼下載】

請點擊:背景顏色background-color 下載本實例相關(guān)素材及源碼

 

標簽: CSS  背景  顏色