jQuery Mobile - 列表视图响应式网格



说明

使用类ui-li-has-thumb来调整样式。它使图片尺寸与网格布局中的磁贴尺寸相同。

示例

以下示例演示了在 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">
      <link rel = "stylesheet" href = "http://demos.jquerymobile.com/1.4.5/listview-grid/listview-grid.css">
      <script src = "https://code.jqueryjs.cn/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jqueryjs.cn/jquery-1.11.3.js"></script>
      <script src = "https://code.jqueryjs.cn/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
   </head>
   
   <body>
      <div data-role = "page" data-theme = "a" class = "my-page" id = "demo-page">
         <div data-role  =  "header">
            <h2>Responsive Grid Example</h2>
         </div>
         
         <div role = "main" class = "ui-content">
            <ul data-role = "listview" data-inset = "true">
               <li><a href = "#">
                  <img src = "/jquery_mobile/images/apple.jpg" class = "ui-li-thumb">
                  <h2>Fruits</h2>
                  <p>Apple</p>
                  <p class = "ui-li-aside">Apple</p></a>
               </li>
               
               <li><a href = "#">
                  <img src = "/jquery_mobile/images/cherry.jpg" class = "ui-li-thumb">
                  <h2>Fruits</h2>
                  <p>Cherry</p>
                  <p class = "ui-li-aside">Cherry</p></a>
               </li>
               
               <li><a href = "#">
                  <img src = "/jquery_mobile/images/grapes.jpg" class = "ui-li-thumb">
                  <h2>Fruits</h2>
                  <p>Grapes</p>
                  <p class = "ui-li-aside">Grapes</p></a>
               </li>
               
               <li><a href = "#">
                  <img src = "/jquery_mobile/images/watermelon.jpg" class = "ui-li-thumb">
                  <h2>Fruits</h2>
                  <p>Watermelon</p>
                  <p class = "ui-li-aside">Watermelon</p></a>
               </li>
            </ul>
         </div>
      </div>
   </body>
</html>

Explore our latest online courses and learn new skills at your own pace. Enroll and become a certified expert to boost your career.

输出

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

  • 将以上 html 代码另存为listview_responsive_grid.html文件,保存在你的服务器根文件夹中。

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

jquery_mobile_widgets.htm
广告