好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

css background-color属性怎么用?

background-color属性是用来设置元素的背景颜色(纯色)的,这种颜色会填充元素的内容、内边距和边框区域,扩展到元素边框的外边界(但不包括外边距)。

CSS background-color属性

作用: 设置元素的背景颜色。

background-color:颜色值;

说明: background-color 属性为元素设置一种纯色背景。这种颜色会填充元素的内容、内边距和边框区域,扩展到元素边框的外边界(但不包括外边距)。如果边框有透明部分(如虚线边框),会透过这些透明部分显示出背景色。

提示: 使用背景色和文本颜色,使文本易于阅读。

CSS background-color属性的使用示例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<style type="text/css">
body {background-color: yellow}
h1 {background-color: #00ff00}
h2 {background-color: transparent}
p {background-color: rgb(250,0,255)}
p.no2 {background-color: gray; padding: 20px;}
</style>
</head>
<body>
<h1>这是标题 1</h1>
<h2>这是标题 2</h2>
<p>这是段落</p>
<p class="no2">这个段落设置了内边距。</p>
</body>
</html>

效果图:

以上就是本篇文章的全部内容,希望能对大家的学习有所帮助。更多精彩内容大家可以关注Gxlcms相关教程栏目!!!

以上就是css background-color属性怎么用?的详细内容,更多请关注Gxlcms其它相关文章!

查看更多关于css background-color属性怎么用?的详细内容...

  阅读:48次