【问题标题】:Seamless start of mobile version of site when needed?需要时无缝启动移动版网站?
【发布时间】:2013-06-15 11:14:48
【问题描述】:

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

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

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

【问题讨论】:

  • 使用 CSS 媒体查询。
  • 如果您还有什么需要,尽管问!

标签: javascript mobile responsive-design


【解决方案1】:

您可以重定向到移动页面

<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 media query

【讨论】:

    猜你喜欢
    • 2019-10-19
    • 1970-01-01
    • 1970-01-01
    • 2021-06-27
    • 2012-04-08
    • 1970-01-01
    • 1970-01-01
    • 2016-04-23
    • 1970-01-01
    相关资源
    最近更新 更多