我需要强制我的网站在移动景观视图桌面模式。通过使用meta tag width=“1024”,网站在桌面模式下以移动纵向模式加载,但对于横向模式,它不起作用。
最佳答案
简而言之,你不能也不应该通过网站控制用户的操作系统行为。
您可以使用以下问题的答案显示警告:强制网站仅以横向模式显示
或者,您可以使用以下代码(取自http://www.quora.com/Can-I-use-Javascript-to-force-a-mobile-browser-to-stay-in-portrait-or-landscape-mode)强制您的布局看起来像横向的,甚至在纵向模式下也是如此:
@media screen and (orientation:landscape) {
#container {
-ms-transform: rotate(-90deg); /* IE 9 */
-webkit-transform: rotate(-90deg); /* Chrome, Safari, Opera */
transform: rotate(-90deg);
width: /* screen width */ ;
height: /* screen height */ ;
overflow: scroll;
}
}
来源:How do you force a website to be in landscape mode when viewed on a mobile device?
关于javascript - 移动环境中的网站桌面模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48260200/