【问题标题】:jQuery Mobile - Fixed Header based on device orientationjQuery Mobile - 基于设备方向的固定标题
【发布时间】:2012-05-28 21:39:32
【问题描述】:

我目前正在开发一个移动设备网站,​​我正在使用 jquery mobile。

我使用以下方法将标题放在固定位置:

<header data-role="header" data-position="fixed">

这很好用,但是当在设备上以横向模式查看页面时,页眉会占用大量空间。

jquery mobile 是否可以仅在纵向模式下设置 data-position="fixed" 而在横向模式下设置 NOT 固定标题?

提前致谢!

【问题讨论】:

    标签: jquery mobile


    【解决方案1】:

    您可以绑定到orientationchange 事件并在标题上调用$("[data-position='fixed']").fixedtoolbar('hide');

    这是讨论固定工具栏http://jquerymobile.com/demos/1.1.0/docs/toolbars/bars-fixed-methods.html 上可用方法的jQuery Mobile 页面。

    这些是可用的事件http://jquerymobile.com/demos/1.1.0/docs/api/events.html,其中之一是orientationchange

    您可以尝试使用带有数据位置属性而不是#header 的实际选择器。可能需要进行一些调试才能使其正常工作,但没有理由不这样做。

    【讨论】:

    • 您能详细说明一下吗?这是我尝试过的,但它不起作用: 按钮有效,但没有任何反应
    • 非常感谢!现在完美运行,流畅可靠,棒极了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-28
    • 1970-01-01
    • 2017-05-27
    • 1970-01-01
    相关资源
    最近更新 更多