jQuery Mobile - 頁首中的導航欄



描述

您可以在頁首區域塊內新增導航欄容器,將導航欄新增到頁面的頂部。

示例

以下示例演示了 jQuery Mobile 中使用“頁首中的導航欄”。

<!DOCTYPE html>
<html>
   <head>
      <title>Navbars in headers</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 data-role = "header" style = "overflow:hidden;">
         <h2>This is Header</h2>
         <a href = "#" data-icon = "gear" class = "ui-btn-right">Options</a>
         <div data-role = "navbar">
            <ul>
               <li><a href = "#" class = "ui-btn-active">Home</a></li>
               <li><a href = "#">About Us</a></li>
               <li><a href = "#">Contact Us</a></li>
            </ul>
         </div>
      </div>
   </body>
</html>

輸出

我們執行以下步驟,瞭解上述程式碼如何工作 -

  • 將上述 HTML 程式碼另存為 navbar_headers.html 檔案,儲存在您的伺服器根資料夾下。

  • 使用以下方式開啟此 HTML 檔案:https:///navbar_headers.html,將顯示以下輸出。

jquery_mobile_widgets.htm
廣告
© . All rights reserved.