<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 4 年前。
标签 css orientation tablet
<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 4 年前。
我创建了一个只能在平板电脑上以横向模式查看的网站。
如果用户以纵向模式加载网站,是否可以使用 CSS 隐藏网站并显示图像/文本?
预先感谢您的帮助, 泽波波
最佳答案
是的,您可以使用 CSS 媒体查询。
代码是从 MDN 文档中复制的。这解释了如何使用横向和纵向方向。
body {
display: flex;
}
div {
background: yellow;
}
@media (orientation: landscape) {
body {
flex-direction: row;
}
}
@media (orientation: portrait) {
body {
flex-direction: column;
}
}
<div>Box 1</div>
<div>Box 2</div>
<div>Box 3</div>
使用时要小心。没有提供实际的兼容性列表。
关于css - 使用 CSS 在平板电脑上禁用纵向模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54253193/