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

Seamless start of mobile version of site when needed?

本文关键字:网站 移动 版本 启动      更新时间:2023-09-26

我的页面中有javascript,可以检测移动浏览器并对网站进行css调整,使其适合移动使用。

但该网站首先仍以"桌面"版本显示,然后需要一些时间来重新格式化。这会产生不愉快的加载体验。

我很欣赏一个关于如何使用js或任何其他方式立即显示移动版本而不是桌面版本的好方法。

你可以重定向到手机页面

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

或者对于同页css修复使用:

@media screen and (max-width:800px) {
// then put your mobile css in here
}

同样的事情,但特定于iPhone 5

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

更多信息在这里:http://css-tricks.com/snippets/css/media-queries-for-standard-devices/和iPhone 5 CSS媒体查询