简体   繁体   English

何时需要无缝启动网站的移动版本?

[英]Seamless start of mobile version of site when needed?

I have javascript in my page that detects mobile browsers and makes css adjustments to site, making it appropriate for mobile use. 我的网页上有JavaScript,可检测移动浏览器并对网站进行CSS调整,使其适合移动使用。

But the site first shows up still in "Desktop" version and then takes some time to reformat itself. 但是该站点首先仍然显示为“桌面”版本,然后需要一些时间来重新格式化自身。 This produces upleasant load experience. 这会产生令人愉悦的负载体验。

I appreciate a good recipe about how to instantly show mobile version instead of desktop version, with js or any other ways. 我赞赏如何使用js或任何其他方式立即显示移动版本而不是桌面版本的好方法。

You can do a redirect to a mobile page 您可以重定向到移动页面

<script type="text/javascript">
<!--
if (screen.width <= 700) {
document.location = "/mobile";
}
//-->
</script>

Or for a same-page css fix use: 或用于同一页面的CSS修复程序使用:

@media screen and (max-width:800px) {

// then put your mobile css in here

}

Same thing, but specific to iPhone 5 相同,但特定于iPhone 5

@media screen and (device-aspect-ratio: 40/71)
{

}

more info here: http://css-tricks.com/snippets/css/media-queries-for-standard-devices/ and iPhone 5 CSS media query 此处提供更多信息: http : //css-tricks.com/snippets/css/media-queries-for-standard-devices/iPhone 5 CSS媒体查询

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM