R3y*_*R3y 4 html css html5 css-position css3
还有其他方法可以在section标签中添加背景颜色吗?除了使用之外body {background-color: blue;},还有哪些方法可以将背景颜色添加到部分中?
我试图添加这样的部分背景颜色:
<!DOCTYPE html>
<html>
<head>
<title>Testing</title>
<style>
#ABC {
background-color: blue;
}
</style>
</head>
<body>
<section id="ABC">
</section>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我的浏览器没有显示颜色.
它因为#ABC没有任何内容或没有高度!
看下面我设置高度时发生的事情.
<!DOCTYPE html>
<html>
<head>
<title>Testing</title>
<style>
#ABC {
background-color: blue;
height: 100%;
position: absolute;
top: 0;
left: 0;
width: 100%;
}
body{
background: grey;
margin: 0;
}
</style>
</head>
<body>
<section id="ABC">
</section>
</body>
</html>Run Code Online (Sandbox Code Playgroud)