jQuery Mobile - 導航欄圖示



描述

要在導航欄中新增圖示,請使用data-icon 屬性新增到每個錨點。預設情況下,圖示置於文字頂部。

範例

以下範例演示了在 jQuery Mobile 中使用導航欄圖示

<!DOCTYPE html>
<html>
   <head>
      <title>Navbar Icons</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 = "navbar">
         <ul>
            <li><a href = "#" data-icon = "mail">Messages</a></li>
            <li><a href = "#" data-icon = "user" class = "ui-btn-active">Friends</a></li>
            <li><a href = "#" data-icon = "star">Notifications</a></li>
         </ul>
      </div>
   </body>
</html>

輸出

讓我們執行以下步驟,看看上面的程式碼如何運作:-

  • 將上述 html 程式碼另存為navbar_icons.html 檔案,儲存在伺服器根資料夾中。

  • 以 https:///navbar_icons.html 開啟此 HTML 檔案,將顯示以下輸出。

jquery_mobile_widgets.htm
廣告
© . All rights reserved.