css - 在小分辨率下,一个 div 覆盖另一个(flex)
问题描述
我有这个代码
.div1{
width:100%;
}
.div2{
width:100%;
}
.div3{
width:100%;
}
.div4{
width:100%;
}
@media(max-width:800px){
.div1,.div2,.div3,.div4{
width:100%;
height:100%;
}
.flexyy{
display:flex;
flex-direction:row;
flex: 1;
flex-wrap:wrap;
}
}
<div class='flexyy'>
<div class='div1'>....</div>
<div class='div2'>....</div>
<div class='div3'>....</div>
<div class='div4'>....</div>
</div>
当我将浏览器的大小调整到 800px 以下时。div3 覆盖在 div2 上,我不想要这个。我希望每个 div 都有 100% 的宽度 请帮助并为我的英语不好在此致歉
解决方案
添加 box-sizing:border-box; 可能会帮助你
* {
box-sizing:border-box;
}
.div{
width: 100%;
border: 1px solid black;
padding:5px;
}
.flexyy{
display: flex;
flex-direction: column;
flex: 1;
text-align: justify;
}
@media(max-width:800px){
.flexyy{
flex-direction: row;
flex-wrap: nowrap;
}
}
<div class='flexyy'>
<div class='div'>
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has
</div>
<div class='div'>
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has
</div> <div class='div'>
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has
</div> <div class='div'>
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has
</div>
</div
推荐阅读
- selenium - 全选并使用 Selenium 提取
- spring - 是否可以将 com.google.common.collect.Table (番石榴库的一部分)放在 redis 中以进行持久存储?
- javascript - 如何将 javascript 动态数组转换为具有自定义键名的多个对象的数组
- adfs - 在 ADFS 中创建依赖方信任时出错
- java - 将 MyBatis 从 3.0.6 升级到 3.5.6 后在 selectOne 查询上获取空对象
- google-sheets - Google 表格 - 拆分日期的公式
- python - 从数据框字典中删除拼写错误
- ckeditor5 - 如何在 CKEditor 5 中构建多层工具栏下拉菜单?
- android - 对齐两个重叠的线性布局,如两行
- python - 如何将已通过身份验证的用户从登录页面重定向到 django 的主页?