怎么用css定义部分背景颜色

html-css014

怎么用css定义部分背景颜色,第1张

需要准备的材料分别有:电脑、浏览器、html编辑器。

1、首先,打开html编辑器,新建html文件,例如:index.html。

2、在index.html中的<style>标签中,输入css代码:div{background-color: #0b93d5}。

3、浏览器运行index.html页面,此时成功实现了只在文字的后面又蓝色背景色。

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

设置h1的样式为:

h1{

background-color:#678

color:white;

}

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

<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>