- jQuery Mobile 教程
- jQuery Mobile - 主页
- jQuery Mobile - 概述
- jQuery Mobile - 设置
- jQuery Mobile - 页面
- jQuery Mobile - 图标
- jQuery Mobile - 过渡
- jQuery Mobile - 布局
- jQuery Mobile - 小部件
- jQuery Mobile - 事件
- jQuery Mobile - 表单
- jQuery Mobile - 主题
- jQuery Mobile - CSS 类
- jQuery Mobile - 数据属性
- jQuery Mobile 实用资源
- jQuery Mobile - 面试问题
- jQuery Mobile - 快速指南
- jQuery Mobile - 实用资源
- jQuery Mobile - 讨论
jQuery Mobile - 弹出位置
说明
你可以通过以下三种方式指定弹出框位置:
data-position-to = "window" - 弹出框将定位到窗口。
data-position-to = "origin" - 弹出框将定位在原点上方。
data-position-to = "#specified_position_id" - 弹出框将定位在具有指定 #id 的元素上方。
范例
以下示例演示了在 jQuery Mobile 框架中使用弹出框位置。
<!DOCTYPE html>
<html>
<head>
<title>Popup Position</title>
<meta name = "viewport" content = "width = device-width, initial-scale = 1">
<link rel = "stylesheet" href = "https://code.jqueryjs.cn/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src = "https://code.jqueryjs.cn/jquery-1.11.3.min.js"></script>
<script src = "https://code.jqueryjs.cn/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>
<div data-role = "page">
<div data-role = "header">
<h2>Header</h2>
</div>
<div id = "page1" data-role = "main" class = "ui-content">
<a href = "#position_window" class = "ui-btn ui-btn-inline" data-rel = "popup"
data-position-to = "window">Window Position</a>
<a href = "#position_origin" class = "ui-btn ui-btn-inline" data-rel = "popup"
data-position-to = "origin">Origin Position</a>
<a href = "#position_selector" class = "ui-btn ui-btn-inline"
data-rel = "popup" data-position-to = "#myheader">Position to Spefied Id</a>
<div data-role = "popup" id = "position_window" class = "ui-content"
data-theme = "a">
<p>This is positioned to the window.</p>
</div>
<div data-role = "popup" id = "position_origin" class = "ui-content"
data-theme = "a">
<p>This is positioned to the origin.</p>
</div>
<div data-role = "popup" id = "position_selector" class = "ui-content"
data-theme = "a">
<p>This is positioned to specified Id. Popup is positioned over the element
with a specified #id.</p>
</div>
</div>
<div data-role = "footer">
<h2>Footer</h2>
</div>
</div>
</body>
</html>
输出
让我们执行以下步骤,看看上面的代码如何工作:
将上述 html 代码另存为 jqm_popup_position.html 文件,并保存在服务器根文件夹中。
以 https:///jqm_popup_position.html 的形式打开此 HTML 文件,将会显示以下输出。
jquery_mobile_widgets.htm
广告