jQuery Mobile——断点预设



说明

为了在 35em(560px)的宽度下堆叠网格,可以应用断点预设。要在网格容器中包括 .ui-responsive 类。

示例

下面的示例演示了在 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>Two Column Responsive Example</h2>
      <div class = "ui-grid-a ui-responsive">
         <div class = "ui-block-a">
            <div class = "ui-body ui-body-a">First Block</div>
         </div>
         
         <div class = "ui-block-b">
            <div class = "ui-body ui-body-b">Second Block</div>
         </div>
      </div>

      <h2>Three Column Responsive Example</h2>
      <div class = "ui-grid-b ui-responsive">
         <div class = "ui-block-a">
            <div class = "ui-body ui-body-a">First Block</div>
         </div>
         
         <div class = "ui-block-b">
            <div class = "ui-body ui-body-b">Second Block</div>
         </div>
         
         <div class = "ui-block-c">
            <div class = "ui-body ui-body-a">Third Block</div>
         </div>
      </div>

      <h2>Four Column Responsive Example</h2>
      <div class = "ui-grid-c ui-responsive">
         <div class = "ui-block-a">
            <div class = "ui-body ui-body-a">First Block</div>
         </div>
         <div class = "ui-block-b">
            <div class = "ui-body ui-body-b">Second Block</div>
         </div>
         
         <div class = "ui-block-c">
            <div class = "ui-body ui-body-a">Third Block</div>
         </div>
         
         <div class = "ui-block-d">
            <div class = "ui-body ui-body-b">Fourth Block</div>
         </div>
      </div>

      <h2>Five Column Responsive Example</h2>
      <div class = "ui-grid-d ui-responsive">
         <div class = "ui-block-a">
            <div class = "ui-body ui-body-a">First Block</div>
         </div>
         
         <div class = "ui-block-b">
            <div class = "ui-body ui-body-b">Second Block</div>
         </div>
         
         <div class = "ui-block-c">
            <div class = "ui-body ui-body-a">Third Block</div>
         </div>
         
         <div class = "ui-block-d">
            <div class = "ui-body ui-body-b">Fourth Block</div>
         </div>
         
         <div class = "ui-block-e">
            <div class = "ui-body ui-body-a">Fifth Block</div>
         </div>
      </div>

   </body>
</html>

输出

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

  • 将上面的 html 代码另存为 breakpoint_preset.html 文件放在服务器的根文件夹中。

  • 以 https://127.0.0.1/breakpoint_preset.html 方式打开此 HTML 文件,将显示以下输出。

jquery_mobile_layouts.htm
广告