【发布时间】:2023-03-21 16:51:01
【问题描述】:
我正在尝试使我的橙色 div 获得所有高度的空白。我使用 1920x1080 显示器。当我在我的页面中打开底部代码时,我在红色、蓝色和绿色 div 下有空白区域。我想要橙色 div 将我的红色、蓝色、绿色 div 向下移动并填充它们下方的空白区域。
这个想法是网站自动填充浏览器窗口而没有滚动条。
我尝试写 100% 而不是 700px,但是当我的属性为 100% 时,橙色 div 消失了。
谁能告诉我为什么会这样,我的错误在哪里,我该如何防止它。
还有其他方法可以为我的红色、蓝色和绿色 div 提供相等的空间吗?我计算出 100% 的页面除以 3 的周期为 33.3333。这就是为什么我将宽度设置为 33.33% 但它并没有完全填满页面。
.wrapper{
position: relative;
}
.pink{
background-color: pink;
height: 100px; width: 100%;
position: relative;
}
.orange{
background-color: orange;
height: 700px; width: 100%;
position: relative;
margin: 0px 0px 0px 0px;
}
.red{
background-color: red;
height: 300px; width: 33.33%;
position: relative;
float: left;
}
.blue{
background-color: blue;
height: 300px; width: 33.33%;
position: relative;
float: left;
}
.green{
background-color: green;
height: 300px; width: 33.33%;
position: relative;
float: left;
}
<div class="wrapper">
<div class="pink"></div>
<div class="orange"></div>
<div class="red"></div><div class="blue"></div><div class="green"></div>
</div>
【问题讨论】:
-
你是指背景中的空白吗?
-
jsfiddle jsfiddle.net/sgymotns
-
你的问题不清楚
-
你可以通过flexbox来均衡红蓝绿的宽度。
-
@dreamhunter 你想提供什么信息来让我的问题更清楚?