怎么在CSS里面更改h1的背景颜色和字体颜色?

html-css07

怎么在CSS里面更改h1的背景颜色和字体颜色?,第1张

它们二者分别使用属性color和background-color来实现的.

设置h1的样式为:

h1{

background-color:#678

color:white;

}

将背景色设置为#678,也就是相当与#667788,并将文字颜色设置为白色。

因为“background: #00FF00”后面没有添加“”符号,浏览器将“background”解析成了“background: #00FF00 font-size:80px”,所以背景和字体大小不能同时作用。

1、新建html文档,在body标签中添加一些p标签,这时网页中将会输出p标签默认的背景颜色和字体大小:

2、为p标签设置“background”属性,属性值为颜色,这时p标签的背景颜色将会变成之前设置的颜色:

3、为p标签设置“font-size”属性,属性值为字体大小,这时p标签的字体大小将会变成之前设置的字体大小:

<div style="width:800pxheight:600pxbackground:url(https://www.taopic.com/uploads/allimg/130427/240403-13042F61F080.jpg) no-repeat center / cover">背景图

<div style="width:400pxheight:200pxmargin:200px autobackground-color:rgba(0,0,0,0.5)color:#ffftext-align:centerline-height:200px">这是文字这是文字</div>

</div>