jQuery Mobile - Listview Responsive Grid


The style is adjusted using the class ui-li-has-thumb. It makes the image size as same as of the tiles in the grid layout.


Following example demonstrates the use of responsive grid listview in the jQuery Mobile.

<!DOCTYPE html>
      <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>
      <div data-role = "page" data-theme = "a" class = "my-page" id = "demo-page">
         <div data-role  =  "header">
            <h2>Responsive Grid Example</h2>
         <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">
                  <p class = "ui-li-aside">Apple</p></a>
               <li><a href = "#">
                  <img src = "/jquery_mobile/images/cherry.jpg" class = "ui-li-thumb">
                  <p class = "ui-li-aside">Cherry</p></a>
               <li><a href = "#">
                  <img src = "/jquery_mobile/images/grapes.jpg" class = "ui-li-thumb">
                  <p class = "ui-li-aside">Grapes</p></a>
               <li><a href = "#">
                  <img src = "/jquery_mobile/images/watermelon.jpg" class = "ui-li-thumb">
                  <p class = "ui-li-aside">Watermelon</p></a>


Let's carry out the following steps to see how the above code works −

  • Save the above html code as listview_responsive_grid.html file in your server root folder.

  • Open this HTML file as http://localhost/listview_responsive_grid.html and the following output will be displayed.

Kickstart Your Career

Get certified by completing the course

Get Started