jQuery Mobile - 網格中的基本按鈕



說明

在按鈕的左側和右側都有邊距間隙。當寬度為 100% 時,不會直接對元素應用邊距,將按鈕包裝在 div 標記內以獲得與其他按鈕相同的邊距空間。

示例

以下示例演示瞭如何在 jQuery Mobile 中使用基本按鈕網格。

<!DOCTYPE html>
<html>
   <head>
      <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>
      <h2>Basic Button Grid Example</h2>
      <div class = "ui-grid-b">
         <div class = "ui-block-a">
            <a class = "ui-btn ui-corner-all ui-shadow ui-btn-b">Using Anchor Tag</a>
         </div>
         
         <div class = "ui-block-b">
            <button class = "ui-btn ui-corner-all ui-shadow ui-btn-a">Using Button</button>
         </div>
         
         <div class = "ui-block-c">
            <input type = "button" value = "Using Input Tag" />
         </div>
      </div>

      <div class = "ui-grid-b">
         <div class = "ui-block-a">
            <label for = "grid-select-1" class = "ui-hidden-accessible">Select</label>
            <select id = "grid-select-1">
               <option>Select</option>
               <option value = "1">First Option</option>
               <option value = "2">Second Option</option>
               <option value = "3">Third Option</option>
            </select>
         </div>
         
         <div class = "ui-block-b">
            <label for = "grid-checkbox-1">Checkbox</label>
            <input type = "checkbox" id = "grid-checkbox-1">
         </div>
         
         <div class = "ui-block-c">
            <label for = "grid-radio-1">Radio</label>
            <input type = "radio" id = "grid-radio-1" />
         </div>
      </div>
      
   </body>
</html>

輸出

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

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

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

jquery_mobile_layouts.htm
廣告
© . All rights reserved.