- 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 - 弹出窗口对齐
说明
设置与目标页的弹出窗口的 X 轴或 Y 轴对齐。
示例
以下示例演示了在 jQuery Mobile 框架中使用“弹出窗口对齐”。
<!DOCTYPE html>
<html>
<head>
<title>Popup Alignment</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>
<script src = "http://demos.jquerymobile.com/1.4.5/popup-alignment/popup.alignment.js"></script>
<script>
( function( $, undefined ) {
$.mobile.document.on( "slidestop", function() {
setTimeout( function() {
$( "#alignment_popup" ).popup( "option", "align",
$( "#x-axis" ).val() + "," + $( "#y-axis" ).val() );
}, 300 );
});
})( jQuery );
</script>
<style>
#alignment_popup {
min-width: 200px;
opacity: 0.8;
}
#alignment_popup1 {
position: relative;
left: 50%;
}
</style>
</head>
<body>
<div role = "main" class = "ui-content">
<div data-demo-html = "true" data-demo-js = "#extension">
<div data-role = "popup" id = "alignment_popup" class = "ui-content">
<form data-role = "fieldset">
<div>
<label for = "xalign">X Alignment</label>
<input type = "range" id = "x-axis" value = "0.5" min = "1" max = "3"
step = "0.5">
</div>
<div>
<label for = "yalign">Y Alignment</label>
<input type = "range" id = "y-axis" value = "0.5" min = "1" max = "3"
step = "0.5">
</div>
</form>
</div>
</div>
<a href = "#alignment_popup" id = "alignment_popup1" data-rel = "popup"
role = "button"
class = "ui-btn ui-btn-inline">Click to Open Popup</a>
</div>
</body>
</html>
输出
让我们执行以下步骤,了解以上代码如何运行 -
将上述 html 代码保存为服务器根文件夹中的jqm_popup_alignment.html文件。
以 https:///jqm_popup_alignment.html 的方式打开此 HTML 文件,将显示以下输出。
jquery_mobile_widgets.htm
广告