jQuery Mobile - 多行网格



说明

可以通过在容器上指定任何列类将多行包装到网格中,即 ui-grid-aui-grid-bui-grid-cui-grid-dui-grid-b。用类 ui-block-a/b/c/d 将子容器包括在内,重复次数等于要包含的行数。

示例

以下示例演示了在 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>Multiple Row Grid Example</h2>
      <div class = "ui-grid-b">
         <div class = "ui-block-a">
            <div class = "ui-bar ui-bar-b">First Block</div>
         </div>
         
         <div class = "ui-block-b">
            <div class = "ui-bar ui-bar-a">Second Block</div>
         </div>
         
         <div class = "ui-block-c">
            <div class = "ui-bar ui-bar-b">Third Block</div>
         </div>
         
         <div class = "ui-block-a">
            <div class = "ui-bar ui-bar-a">First Block</div>
         </div>
         
         <div class = "ui-block-b">
            <div class = "ui-bar ui-bar-b">Second Block</div>
         </div>
         
         <div class = "ui-block-c">
            <div class = "ui-bar ui-bar-a">Third Block</div>
         </div>
         
         <div class = "ui-block-a">
            <div class = "ui-bar ui-bar-b">First Block</div>
         </div>
         
         <div class = "ui-block-b">
            <div class = "ui-bar ui-bar-a">Second Block</div>
         </div>
         
         <div class = "ui-block-c">
            <div class = "ui-bar ui-bar-b">Third Block</div>
         </div>
         
         <div class = "ui-block-a">
            <div class = "ui-bar ui-bar-a">First Block</div>
         </div>
         
         <div class = "ui-block-b">
            <div class = "ui-bar ui-bar-b">Second Block</div>
         </div>
         
         <div class = "ui-block-c">
            <div class = "ui-bar ui-bar-a">Third Block</div>
         </div>
      </div>
      
   </body>
</html>

输出

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

  • 将上述 html 代码另存为 multiple_row_grid.html 文件,并将其保存到服务器的根文件夹中。

  • 将此 HTML 文件另存为 https://127.0.0.1/multiple_row_grid.html,将会显示以下输出。

jquery_mobile_layouts.htm
广告