【发布时间】:2019-06-15 19:35:03
【问题描述】:
我制作了一个响应式网页,其中最大宽度为 768 像素(通过媒体查询),主容器内的 div 假设更改为 inline-block,以便当用户单击链接时页面将水平滚动到 div 的 id。该页面设置了溢出:隐藏,因此它仅使用 id/anchor 进行导航。
问题是,当我在移动设备中进行预览时,容器刚刚展开,我可以完全滑动页面。甚至假设在视口中心的菜单按钮也进入了容器的中心。并在其下方留下巨大的空白。但是在桌面浏览器中它做得很好。所以我认为它与 nowrap 函数有关。
它在移动版和桌面版的 Firefox 中都可以使用。它在IE桌面上工作。它不适用于 Chrome 移动设备,但似乎可以在桌面设备中使用。并且在 Safari 移动端失败,尚未在桌面端测试。
我试图删除 white-space: nowrap 函数只是为了发现 div 没有像它假设的那样堆叠 inline-block。我尝试了指定容器的宽度和最小宽度,但没有成功。我试过float:left,位置值和一堆我不记得的东西。没什么变化。
HTML
<div id="container">
<div id="company" class="company">
<iframe src="main.html">
</iframe>
</div>
<div id="content" class="content">
<iframe src="content.html">
</iframe>
</div>
<div id="system" class="system">
<iframe src="system.html">
</iframe>
</div>
</div>
css
body{
overflow: hidden;
}
#container {
height: 100vh !important;
min-height: 100vh !important;
}
#container .company, #container .content, #container .system {
display: block;
height: 100vh !important;
min-height: 100vh !important;
}
@media screen and (max-width:768px) {
#container {
display: block;
white-space: nowrap;
}
#container .company, #container .content, #container .system {
display: inline-block;
}
}
iframe {
width: 100vw !important;
min-width: 100vw !important;
height: 100vh !important;
min-height: 100vh !important;
border: none;
}
我所期望的(Chrome 桌面版) https://kamalmasrun.files.wordpress.com/2019/01/desktop.jpg
但只在移动设备上出现 https://kamalmasrun.files.wordpress.com/2019/01/screenshot_20190122-120510.png
非常感谢您的帮助,我首先感谢大家的帮助 =)。
【问题讨论】:
标签: mobile browser whitespace nowrap