Jquery popup menu no stick with header

青春壹個敷衍的年華 提交于 2019-12-12 00:20:06

问题


I have a right side button in my header. When click the button, a popup list menu will display. But when I scroll down the page, header is scroll down. But the popup menu is keep stick at top. How to I make popup menu stick with header? Below is my code.

<html>
<head> 
    <title>My Page</title> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.css" />
    <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script>

    <style>
    </style>
</head> 
<body> 
    <div data-role="page">
        <div data-role="header" data-position="fixed">                 
            <h1>Chats</h1>
            <a id="chatpageicon"  href="#photopopup" data-rel="popup" data-position-to="origin"  data-role="button" data-theme="b" data-icon="plus" data-form="ui-icon"  data-iconpos="notext"  class="ui-btn-b ui-shadow ui-corner-all ui-icon-plus ui-btn-right  ui-btn-icon-notext ui-btn-up-b" ></a>
            <div data-role="popup" id="photopopup">
                <ul data-role="listview" data-inset="true" style="min-width:150px;position:fixed;right:30px;">
                    <li><a href="#">List1</a></li>
                    <li><a href="#">List2</a></li>
                </ul>
            </div>
        </div>

        <div data-role="content">    
            <p>asd</p>
            <p>asd</p>
            <p>asd</p>
            <p>asd</p>
            <p>asd</p>
            <p>asd</p>
            <p>asd</p>
            <p>asd</p>
            <p>asd</p>
            <p>asd</p>
            <p>asd</p>
            <p>asd</p>
            <p>asd</p>
            <p>asd</p>
            <p>asd</p>
            <p>asd</p>
            <p>asd</p>
            <p>asd</p>
            <p>asd</p>
            <p>asd</p>
            <p>asd</p>
            <p>asd</p>
        </div>
    </div>
</body>
</html>

Before scroll:

After scroll down, the popup menu still keep at same position:

How do I make it stick together with my header? Even scroll to the end. Thanks

Updated:
I edited my code (refer "Nisal Upendra" solution), the issue for second screen shot is fixed. But if I scroll down first, and click the header button. the menu is popup at middle of the screen as image as below:


回答1:


You need to add style="min-width:150px;position:fixed;right:30px;" to your popup styling. Here's a fiddle: https://jsfiddle.net/hym405nz/1/



来源:https://stackoverflow.com/questions/32604991/jquery-popup-menu-no-stick-with-header

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!