纵向和横向的 CSS 移动导航更改

标签 css class mobile orientation

我的网站上有一系列包含“.iframe1”的页面。 .iframe1 需要在手机的纵向和横向模式下都可见,但我需要调整 2 项以使其正常运行。

1.) 横向模式:完全阻止“#main-header”出现。

2.) 纵向模式:填充我的内容区域的顶部。 (#main-header 在纵向时覆盖了我的内容的顶部。)

我已经完成了#1,但似乎无法弄清楚如何实现#2。我将它们合并为一个任务,因为我觉得如果单独编写它们可能会发生冲突。

以下两个条目都达到了#1 但没有达到#2:

@media only screen and ( min-width: 480px ) and ( max-width: 768px ) {
#main-header {
display: none !important;
}
.iframe1 {
padding-top: 30px !important;
}
}

@media only screen and (orientation:landscape) and (max-width: 768px) {
#main-header {
display: none !important;
}
.iframe1 {
padding-top: 30px !important;
}
}

有人知道如何让#2 工作吗?

提前致谢

千伏

最佳答案

好的,所以我最终通过消除 orientation: 属性并简单地使用 min-widthmax-width 实现了预期的效果>:

@media only screen and ( min-width: 481px ) and ( max-width: 768px ) {
#main-header {
display: none !important;
}
.iframe1 {
padding-top: 30px !important;
}
}

@media only screen and ( max-width: 480px ) {
.iframe1 {
padding-top: 119px !important;
}
}

这样我就能够从横向完全消除 #main-header,并使用适当的 padding-top 将其保持在纵向模式。

千伏

关于纵向和横向的 CSS 移动导航更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33404667/

相关文章:

html - 垂直标题 ionic 离开 CSS 问题

css - 文本放大 flexbox 容器

php - MySQLi 查询返回单个结果——应该是结果数组

python - 是否有与 Ruby 的 respond_to 等效的 Python?

java - 在没有特定属性的情况下访问对象中模型的值

android - 在 Android、iOS 和 Blackberry 上嵌入字体——是否有万无一失的解决方案?

android - 缺少 mips、arm、x86 架构的 Qt 版本

javascript - JQuery Mobile 中非事件复选框的颜色

html - 如何停用输入的内存值?

android - 跨平台移动应用程序 SDK : Write Once Deploy Everywhere