我想要container-2
是完全可见的,但box2
中的框覆盖了它在移动视图中。我不希望大小与box2
中的方框有任何不同,我只想要container 2
被推下来,以便在移动设备中完全可见。如何让一个容器在移动视图中向下推动另一个容器?
body {
margin: 0;
width: 100%;
}
.container {
width: 100%;
height: 100vh;
background-color: rgb(152, 152, 152);
}
.container-2 {
width: 100%;
height: 100vh;
background-color: rgb(46, 6, 6);
}
.box-container {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
width: 100%;
height: 100%;
}
.box1 {
background-color: rgb(65, 186, 186);
width: 50%;
height: 100%;
}
.box2 {
background-color: rgb(92, 191, 124);
width: 50%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
}
@media (max-width: 600px) {
.box1 {
background-color: rgb(65, 186, 186);
width: 100%;
height: 50%;
}
.box2 {
background-color: rgb(92, 191, 124);
width: 100%;
height: 50%;
}
}
<body>
<div class="container">
<div class="box-container">
<div class="box1">
</div>
<div class="box2" id="box">
<div class="box1" style="background-color: blue; height: 50%;"></div>
<div class="box1" style="background-color: green; height: 50%;"></div>
<div class="box1" style="background-color: yellow; height: 50%;"></div>
<div class="box1" style="background-color: orange; height: 50%;"></div>
</div>
</div>
</div>
<div class="container-2">
</div>
</body>
</html>
我已经测试过你的代码,但是我不清楚你遇到了什么问题。对我来说似乎工作正常,但仍然是凌晨3点,所以它可能无法帮助我。 – dippas
box2内的框包含移动视图中的容器2。 – sydluce
我已经在移动视图中进行了测试,并且可以完美地看到'container-2'背景颜色 – dippas