html - CSS HTML窗口大小调整问题
问题描述
当我调整窗口大小时,我需要最后两个 div 位于前两个之下。它这样做了,但是第三个 div 在右边,而第四个 div 在左边,在第三个下面。我似乎找不到原因。像这样:
DIV1 DIV2
DIV3
DIV4
调整大小后,我希望它们看起来像这样:
DIV1 DIV2
DIV3 DIV4
欢迎任何帮助。
谢谢!
HTML:
<div class="section4a">
<div class="list">
<p class="header">South Asia</p>
<p class="country">
Bangladesh <br>
Maldives <br>
Pakistan <br>
Nepal <br>
Bhutan <br>
India
</p>
</div>
<div class="list">
<p class="header">South Asia</p>
<p class="country">
Panama <br>
Nicaragua <br>
Bahamas <br>
Canada <br>
Mexico
</p>
</div>
<div class="list">
<p class="header">Middle East</p>
<p class="country">
Bahrain <br>
Cyprus <br>
Egypt <br>
Iran <br>
Jordan <br>
Kuwait
</p>
</div>
<div class="list">
<p class="header">South America</p>
<p class="country">
Guyana <br>
Paraguay <br>
Colombia <br>
Bolivia <br>
Brazil
</p>
</div>
</div>
CSS:
.section4a {
margin-left: 13%;
margin-top: 155px;
width: 100%;
}
.section4a .list {
float: left;
margin-right: 12%;
}
.section4a .list:after {
content: "";
display: table;
clear: both;
}
解决方案
我会在你的部分元素上使用 display: flex,在列表元素上使用 max-width 。通过这种方式,它可以响应所有屏幕尺寸。而且你也不再需要那种清晰的花车了:)
.section4a {
margin-left: 13%;
margin-top: 155px;
width: 100%;
display: flex;
flex-wrap: wrap;
}
.section4a .list {
min-width: 300px;
}
推荐阅读
- autocad - AutoCAD SCR 文件绘制多段线 - 结果不一致
- reactjs - 在 React 16 中无法通过 this.context 访问 contextType
- scala - 如何将该组列表的功能重新制作为简单递归?
- php - 在 WAMP 和 phppgadmin 上集成 postgreSQL
- javascript - 从 AngularJS 1.5 升级到 1.7 会抛出“无法复制!不支持复制 Window 或 Scope 实例”
- html - DevicePixelRatio 似乎突然与 Windows 比例叠加
- python - 获取二维数组中最近的坐标
- python - 为什么 vgg.prepare() 方法会创建给定图像的 9 个副本?
- python - 用于模式研究的 Python 正则表达式
- php - 如何显示输入数组的验证错误?