jQuery Mobile: Grid

This entry is part 35 of 73 in the series jQuery Mobile

The jQuery Mobile framework provides a simple way to build CSS-based columns that can also be responsive.

We look at a simple example below.

To build a two-column (50/50%) layout, start with a container with a class of ui-grid-a, and add two child containers inside it classed with ui-block-a for the first column and ui-block-b for the second.

2-Column Grid
<!DOCTYPE html>
    <link href='http://code.jquery.com/mobile/1.4.1/jquery.mobile-1.4.1.min.css' rel='stylesheet'/>
    <script src='http://code.jquery.com/jquery-1.10.2.min.js'></script>
    <script src='http://code.jquery.com/mobile/1.4.1/jquery.mobile-1.4.1.min.js'></script>
<div data-role='page'>
    <div data-role='header'><h1>Grid A</h1></div>
    <div class='ui-grid-a'>
            <div class='ui-block-a'><div class='ui-bar ui-bar-a' style='height:60px'>Block A</div></div>
            <div class='ui-block-b'><div class='ui-bar ui-bar-a' style='height:60px'>Block B</div></div>
    </div><!-- /grid-a -->

    <div data-role='footer' data-position='fixed'>
Try The Code


This is the grid-a with a 2-column block.

In the next example, we will use grid-b which is for 3-column block.

Series Navigation<< jQuery Mobile: Filter Reveal
jQuery Mobile: 3-column Grid B >>

Leave a comment

Leave a Reply