- 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.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src = "https://code.jquery.com/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
廣告