css - @media queries for mobile - Portrait vs Landscape
问题描述
I am using media queries to address mobile screens.
Issue i am facing is with text on the header with Portrait vs Landscape. The landscape "top" property takes over the portrait one. Meaning; to position the landscape text properly, on the portrait it gets positioned too high! Any idea what's the solution to this? How to get portrait and landscape to respect each-other properties and not overtake each-other?
Or how would you approach it?
/* Mobile Portrait */
@Media only screen and (max-width: 480px) {
#one{
position: relative;
top: 310px;
}
}
/* Mobile Landscape */
@Media only screen and (max-width: 734px) {
#one{
position: relative;
top: 230px;
}
}
解决方案
我认为您需要颠倒顺序,因为 <480 也是 <784 它遵循顺序中最后的规则。尝试使用它,我通常将媒体查询按从大到小的顺序排列。
/* Mobile Landscape */
@Media only screen and (max-width: 734px) {
#one{
position: relative;
top: 230px;
}
}
/* Mobile Portrait */
@Media only screen and (max-width: 480px) {
#one{
position: relative;
top: 310px;
}
}
推荐阅读
- r - How to define selection range of variable length?
- javascript - 简化 onClick 函数道具
- angular - 为文本的单词动态添加标签组件 - Angular 12
- javascript - 如何在每个刻度之间显示网格线(不显示标签)?
- mysql - 为什么 MySQL 写入磁盘的数据比提交到数据库的数据多 5 倍?
- python - LP最大化问题Python:水电模型
- python - 如何修补python单元测试中的动态导入?
- google-sheets - 当数据添加到范围内的单元格时,拆分 ArrayFormula 抛出 #valueerror
- sql - 使用值更新 NULL 字段
- r - UBCF 模型 - 从推荐器中提取用户相似性