- 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 - 導航欄主題
描述
就像按鈕一樣,導航欄的主題樣本將從其父容器繼承。
每當導航欄位於頁首或頁尾工具欄中時,預設工具欄樣本 a 都將被繼承,除非在標記中設定。
你可以新增樣本類以應用正文樣本(ui-body-a 和 ui-body-b)。你還可以使用data-theme屬性為各個導航欄項設定主題顏色並指定主題樣本。
ui-body 類新增標準正文填充。
示例
以下示例演示了在 jQuery Mobile 中使用導航欄主題。
<!DOCTYPE html>
<html>
<head>
<title>Navbars Themes</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>
</head>
<body>
<div class = "ui-body-a ui-body">
<h3>Swatch "a"</h3>
<div data-role = "navbar">
<ul>
<li><a href = "#" data-icon = "star">A</a></li>
<li><a href = "#" data-icon = "gear">B</a></li>
<li><a href = "#" data-icon = "grid">C</a></li>
<li><a href = "#" data-icon = "arrow-l">D</a></li>
<li><a href = "#" data-icon = "arrow-r">E</a></li>
</ul>
</div>
</div>
<div class = "ui-body-b ui-body">
<h3>Swatch "b"</h3>
<div data-role = "navbar">
<ul>
<li><a href = "#" data-icon = "star">A</a></li>
<li><a href = "#" data-icon = "gear">B</a></li>
<li><a href = "#" data-icon = "grid">C</a></li>
<li><a href = "#" data-icon = "arrow-l">D</a></li>
<li><a href = "#" data-icon = "arrow-r">E</a></li>
</ul>
</div>
</div>
<h3><i>data-theme</i> attribute</h3>
<div data-role = "footer">
<div data-role = "navbar">
<ul>
<li><a href = "#" data-icon = "grid" data-theme = "a">A</a></li>
<li><a href = "#" data-icon = "grid" data-theme = "b">B</a></li>
</ul>
</div>
</div>
</body>
</html>
輸出
讓我們執行以下步驟,瞭解以上程式碼如何工作 −
將以上 html 程式碼另存為navbar_themes.html檔案,儲存到伺服器根資料夾中。
以 https:///navbar_themes.html 格式開啟此 HTML 檔案,將會顯示以下輸出。
jquery_mobile_widgets.htm
廣告