jQuery Mobile - 新增內邊距



說明

導航欄和其他小元件不會有工具欄的任何內邊距。

若要新增內邊距,可以將工具欄的內容包裝在某元素內,然後向該元素新增 ui-bar 類。

你也可以使用自己的自定義 CSS 新增內邊距。

示例

以下示例展示瞭如何在 jQuery Mobile 中使用 新增內邊距

<!DOCTYPE html>
<html>
   <head>
      <title>Adding padding</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 = "footer">
         <div class = "ui-bar">
            <label for = "select-choice-1" class = "ui-hidden-accessible">City:</label>
            <select name = "select-choice-1" id = "select-choice" data-mini = "true" data-inline = "true">
               <option value = "India">Bengaluru</option>
               <option value = "Norway">Oslo</option>
               <option value = "Mauritius">Port Louis</option>
            </select>
         </div>
      </div>
   </body>
</html>

輸出

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

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

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

jquery_mobile_widgets.htm
廣告
© . All rights reserved.