html - 如何解决并排放置 div 的移动问题?
问题描述
我想将 div 并排放置,我做到了。
<div style="width:800px;">
<div style="width:300px; float:left;"></div>
<div style="width:300px; float:right;"></div>
</div>
但在移动设备上,我想显示一个 div,走到行尾并显示其他 div。
谢谢!
解决方案
设置display: none;
为其他 div 并使用@media-query
,然后设置display:inline
了解媒体查询:https ://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries
@media screen and (min-width: 600px){
.other{
display:inline!important;
}
}
<div style="width:800px;">
<div style="width:300px; float:left;">text1</div>
<div style="width:100px;display: none;" class="other">Othe div</div>
<div style="width:300px; float:right;">text2</div>
</div>
推荐阅读
- python - Python脚本随机冻结
- java - JPA Lazy Fetch 在收集时不起作用
- javers - Javers findshadows 在子对象和父对象的某些字段中返回 null
- ios - 不推荐使用“iOS”的产品类型“com.apple.product-type.application.watchapp”。不再支持 WatchKit 1.0
- firebase - 升级到 angular8 后 app.auth 不再是一个函数
- database - 如何在circle ci config.yml中为aws ecs设置数据库配置变量?
- php - 如何修复使用未定义的常量 SORI_DESC - 假定为“SORI_DESC”(这将在 PHP 的未来版本中引发错误)
- c# - 如何将异步函数传递给 ConcurrentDictionary.GetOrAdd 方法?
- github - 在 AppCode 中的 git 克隆存储库期间找不到项目文件
- contiki - Instantcontiki 3.0 中的 Cooja hello-world-example.csc 模拟器给出编译错误:尝试在 boot.h 中使用中毒的“SPMCR”