- 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-theme新增到任何容器(例如頁首、頁尾或內容)來將主題包含在對話方塊中。
包含data-corners = "false"以移除對話方塊的圓角,因為預設情況下圓角被設定為圓角。
data-overlay-theme屬性將覆蓋設定為任何圖案字母。
還可以在對話方塊中使用多個按鈕。透過將{margin-top:0}包含在為頁面指定的類中,可以將對話方塊固定在頂部。 ui-dialog.my-dialog .ui-dialog-contain
例子
以下示例演示了在 jQuery Mobile 中使用樣式和主題對話方塊。
<!DOCTYPE html>
<html>
<head>
<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>
<style>
.ui-dialog.dialog-actionsheet .ui-dialog-contain {
margin-top: 0;
}
</style>
</head>
<body>
<div data-role = "page" id = "page1">
<div data-role = "header" data-theme = "b">
<h2>Header</h2>
</div>
<div role = "main" class = "ui-content">
<a href = "#page2" class = "ui-btn ui-corner-all ui-btn-inline">
Open Dialog</a>
<a href = "#page3" class = "ui-btn ui-corner-all ui-btn-inline">
Photos Dialog</a>
</div>
<div data-role = "footer">
<h4>Footer</h4>
</div>
</div>
<div data-role = "page" data-dialog = "true" id = "page2" data-corners = "false"
data-overlay-theme = "b">
<div data-role = "header">
<h1>First Dialogs</h1>
</div>
<div role = "main" class = "ui-content">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the
1500s.</p>
<a data-rel = "back" class = "ui-btn ui-corner-all ui-btn-inline">Back</a>
</div>
</div>
<div data-role = "page" class = "dialog-actionsheet" data-dialog = "true"
id = "page3">
<div role = "main" class = "ui-content">
<h3>Share Photos</h3>
<a href = "#page4" data-transition = "slidedown" class = "ui-btn ui-shadow
ui-corner-all ui-btn-b">Email</a>
<a href = "#page4" data-transition = "slidedown" class = "ui-btn ui-shadow
ui-corner-all ui-btn-b">Share on Facebook</a>
<a href = "#page4" data-transition = "slidedown" class = "ui-btn ui-shadow
ui-corner-all ui-btn-b">Tweet photo</a>
<a data-rel = "back" class = "ui-btn ui-shadow ui-corner-all ui-btn-a">
Cancel</a>
</div>
</div>
<div data-role = "page" class = "dialog-actionsheet" data-dialog = "true"
id = "page4">
<div role = "main" class = "ui-content">
<h3>Photos uploaded successfully</h3>
<a href = "#page1" class = "ui-btn ui-shadow ui-corner-all ui-btn-a">
View photo page</a>
<a href = "#page1" class = "ui-btn ui-shadow ui-corner-all ui-btn-a">
Done</a>
</div>
</div>
</body>
</html>
輸出
讓我們執行以下步驟,瞭解上面的程式碼如何工作-
將上述 html 程式碼儲存為style_theming.html檔案,並儲存到伺服器根資料夾中。
將此 HTML 檔案作為 https:///style_theming.html 開啟,將顯示以下輸出。
jquery_mobile_pages.htm
廣告