Jquery的弹出式菜单没有标题 [英] Jquery popup menu no stick with header
问题描述
我的标题中有一个右侧按钮。点击按钮时,会弹出一个列表菜单。但是当我向下滚动页面时,标题向下滚动。但弹出式菜单始终保持在顶部。如何使标题的弹出菜单棒?以下是我的代码。
< html>
< head>
< title>我的页面< /标题>
< meta name =viewportcontent =width = device-width,initial-scale = 1>
< link rel =stylesheethref =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 =headerdata-position =fixed>
< h1>聊天< / h1>
p>
我如何使它与我的标题粘在一起?甚至滚动到结尾。感谢
更新:
我编辑了我的代码(请参阅Nisal Upendra解决方案)对于第二个屏幕截图是固定的。但是如果我先向下滚动,然后点击标题按钮。菜单在屏幕中间弹出,如下图所示:
< img src =https://i.stack.imgur.com/jJZCk.pngalt =在这里输入图片描述>
解决方案 您需要在弹出窗口中添加 style =min-width:150px; position:fixed; right:30px;
造型。
这是一个小提琴: https://jsfiddle.net/hym405nz/1/ p>
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:
解决方案 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/
这篇关于Jquery的弹出式菜单没有标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文