简体   繁体   English

jQuery移动面板固定位置不起作用

[英]Jquery mobile panel fixed-position not working

I have a web app with two panels. 我有一个带有两个面板的Web应用程序。 When the panel is selected and displayed, the user can continue to scroll down the entire page. 选择并显示面板后,用户可以继续向下滚动整个页面。 The problem is the panel menu scrolls down with it, leaving a bunch of blank space and the menu back at the top. 问题是面板菜单向下滚动,留下一堆空白,菜单回到顶部。 I tried implementing data-position-fixed= "true" in the div of the panel, but that didn't work. 我尝试在面板的div中实现data-position-fixed= "true" ,但这没有用。 I also added a css constraint of position: Fixed which helped, however when a device is turned to the horizontal position it cuts off half of the menu :/. 我还添加了一个css position: Fixed约束position: Fixed ,这很有帮助,但是,当设备转到水平位置时,它会切断菜单:/的一半。 Thank you for any input! 谢谢您的投入! I am also using Jquery library 1.8.3 and jquery mobile 1.3.0. 我也在使用Jquery库1.8.3和jquery移动版1.3.0。

It should be: 它应该是:

<div data-role="header" data-position="fixed">
    <h1>Fixed Header!</h1>
</div>

not: 不:

<div data-role="header" data-position-fixed="true">
    <h1>Fixed Header!</h1>
</div>

More info Here 更多信息在这里

Using position: fixed; 使用位置:固定 is the right way to handle this. 是处理此问题的正确方法。 You should consider using media queries to change the top & left coordinates on horizontal view. 您应该考虑使用媒体查询来更改水平视图的顶部和左侧坐标。

    div {
        position: fixed;
        top: 10px;
        left: 20px;
    }
    @media all and (max-device-width: 400px) {
     div {
             top: 0;
             left: 0;
             /* change these coordinates to suit when the device is rotated */
         }
    }

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

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