jQuery Mobile - 導航欄第三方圖示



描述

可以在導航欄中新增第三方圖示。要實現此目的,只需新增自定義樣式連結至圖示並將它們放置於導航欄中。

示例

以下示例展示了 jQuery Mobile 中導航欄第三方圖示的使用。

<!DOCTYPE html>
<html>
   <head>
      <title>Navbars 3rd Party 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>
      
      <style>
         .nav-glyphish-example .ui-btn { 
            padding-top: 40px !important; 
         }
         
         .nav-glyphish-example .ui-btn:after { 
            width: 30px!important; 
            height: 30px!important; 
            margin-left: -15px !important;
         }
         
         #home:after { 
            background: url("/jquery_mobile/images/home.png") no-repeat;
         }
         
         #notify:after { 
            background: url("/jquery_mobile/images/notifications.png") no-repeat;
         }
      </style>
   </head>
   
   <body>
      <div data-role = "footer" class = "nav-glyphish-example" data-theme = "a">
         <div data-role = "navbar" class = "nav-glyphish-example" data-grid = "a">
             <ul>
               <li><a href = "#" id = "home" data-icon = "custom">Home</a></li>
               <li><a href = "#" id = "notify" data-icon = "custom">Notifications</a></li>
            </ul>
         </div>
      </div>
   </body>
</html>

輸出

執行以下步驟來檢視上述程式碼如何工作 −

  • 將以上 html 程式碼另存為伺服器根資料夾中的navbar_3rd_party_icons.html 檔案。

  • 以 https:///navbar_3rd_party_icons.html 開啟此 HTML 檔案,將顯示以下內容。

jquery_mobile_widgets.htm
廣告
© . All rights reserved.