html - 当屏幕很小时,如何将 Div 堆叠在一起?
问题描述
有五个div。它们彼此相邻,但在移动设备上查看时会变得很奇怪。只有当屏幕尺寸不足以并排显示它们时,如何才能将这些 div 堆叠在一起?
#a,
#b,
#c,
#d,
#e {
background-color: cyan;
width: 300px;
height: 500px;
margin: 10px;
border-radius: 5%;
}
#wee {
display: flex;
}
<div id="wee">
<div id="a">
stuff
</div>
<div id="b">
weeeeeee
</div>
<div id="c">
i like turtles
</div>
<div id="d">
i don't eat sunglasses.
</div>
<div id="e">
cough cough
</div>
</div>
div 都是彩色的,宽 300 像素,高 500 像素。
解决方案
你可以使用这个:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
#a,
#b,
#c,
#d,
#e {
background-color: cyan;
width: 300px;
height: 500px;
margin: 10px;
border-radius: 5%;
}
#wee {
display: flex;
}
@media screen and (max-width: 900px) {
#wee {
flex-direction: column;
margin: 10px;
}
}
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<div id="wee">
<div id="a">
stuff
</div>
<div id="b">
weeeeeee
</div>
<div id="c">
i like turtles
</div>
<div id="d">
i don't eat sunglasses.
</div>
<div id="e">
cough cough
</div>
</div>
推荐阅读
- ubuntu - 操作系统内存和erlang虚拟内存之间的差异?
- javascript - 如何将字符串值更改为时间戳?Javascript React-Native
- python - 有谁知道这些字符在word文档(docx)的表格中是什么?
- node.js - 如何知道容器已启动并正在运行(Dockerode)?
- azure - ADOS 2020.1 流水线页面布局
- html - 如何以角度创建 HTML?
- codenameone - 代号一中的FTP协议
- django - 此代码如何将两个类相互链接?
- wazuh - 用于 Wazuh 集成的 SSL conf
- python - 如果在更多 N 秒内没有答案然后返回 None 怎么做(因为如果没有发送消息,它将是无限的)