当前位置:软件学堂 > 资讯首页 > 网络编程 > DIV+CSS > CSS背景颜色background-color

CSS背景颜色background-color

2012/11/24 13:12:26作者:佚名来源:网络

移动端

【实例介绍】

CSS背景颜色background-color

在HTML中.设置网页的背景颜色利用的是<body>标签中的bacolor属性,而在CSS中不但可以设置网页的背景颜色,还可以设置文字的背景颜色。在CSS中,背景颜色使用background-color属性来设置。

【基本语法】

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">哭泣不是谁都有的权利<br />       不是每一个人都有权利流泪<br />     也许是故作的坚强。<br /></td>   </tr> </table> </body> </html>

【代码分析】

代码中的background-color.#0C3设置背景颜色为#0c3,在浏览器中预览效果,如图所示。background—color属性可以用于各种网页元素,这里是对单元格应用的属性。

背景颜色background-color运行效果

 【素材及源码下载】

请点击:背景颜色background-color 下载本实例相关素材及源码

 

标签: 背景