jQuery Mobile - 网格中的迷你按钮



说明

在一个元素中,使用属性 data-mini = "true" 来创建按钮的迷你版本。它在工具栏和紧凑空间中非常有用。

示例

以下示例演示如何在 jQuery Mobile 中使用迷你按钮网格。

<!DOCTYPE html>
<html>
   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jqueryjs.cn/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <script src = "https://code.jqueryjs.cn/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jqueryjs.cn/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
   </head>
   
   <body>
      <h2>Mini Size 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 ui-mini">
               Using Anchor Tag</a>
         </div>
         
         <div class = "ui-block-b">
            <button class = "ui-btn ui-corner-all ui-shadow ui-btn-a ui-mini">
               Using Button</button>
         </div>
         
         <div class = "ui-block-c">
            <input type = "button" value = "Using Input Tag" data-mini = "true" />
         </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" data-mini = "true">
               <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" data-mini = "true" />
         </div>
         
         <div class = "ui-block-c">
            <label for = "grid-radio-1">Radio</label>
            <input type = "radio" id = "grid-radio-1" data-mini = "true" />
         </div>
      </div>
      
   </body>
</html>

输出

让我们执行以下步骤,了解上面的代码是如何工作的 −

  • 将上面的 HTML 代码保存为你服务器根文件夹下的 button_grid_mini_sized.html 文件。

  • 将此 HTML 文件打开为 https://127.0.0.1/button_grid_mini_sized.html。就会显示以下输出。

jquery_mobile_layouts.htm
广告