我创建了一个带有 3 个 div 标签的网页,每个 div 中有一些内容,背景颜色设置为 div 元素,我发现 div 元素之间出现了一些空白。我已经尝试了很多,除去使用各种属性,如这些白色空间outline,margin,padding等等,但我失败了。我想在div不使用“浮动”属性的情况下删除我之间的空格。
网页快照
<!DOCTYPE html>
<html>
<head>
<style>
body
{
margin:0px;
background-color:green;
}
.container
{
margin-top:0px;
margin-bottom:0px;
margin-left:10%;
margin-right:10%;
}
.head
{
background-color:gray;
}
.nav
{
background-color:blue;
}
.content
{
background-color:lime;
}
</style>
</head>
<body>
<div class="container">
<div class="head">
<h1>Welcome to my page!</h1>
</div>
<div class="nav">
<h2>some text</h2>
</div>
<div class="content">
<p>Some text in content</p>
</div>
</div>
</body>
</html>Run Code Online (Sandbox Code Playgroud)