jQuery Mobile - Listview 响应式网格
描述
使用 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.jquery.com/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.jquery.com/jquery-1.11.3.min.js"></script> <script src = "https://code.jquery.com/jquery-1.11.3.js"></script> <script src = "https://code.jquery.com/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>
输出
让我们执行以下步骤,看看上面的代码是如何工作的 −
将上述 html 代码保存为服务器根文件夹中的 listview_responsive_grid.html 文件。
将此 HTML 文件打开为 http://localhost/listview_responsive_grid.html,将显示以下输出。