jQuery Mobile’s grids are configurable to support layouts in the range of two to five columns. From an HTML perspective, grids are div elements that are configured with CSS attributes. The Grid is flexible and will consume the entire width of your display. The grids do not contain borders, padding, or margins so they will not interfere with the styles of elements contained within them. Before we look at an example let’s review the standard grid template.

Grid Template

The grid template may be a helpful reference when creating multi-column grids (see Listing 6–1).

Listing 6–1. Grid Template<div data-role="content">

  <!-- Grid container -->
  <div class="<grid-css-attribute>">

    <!-- Blocks -->
    <div class="<block-css-attribute>">Block A</div>
    <div class="<block-css-attribute>">Block B</div>

  </div>
</div>

When creating a grid, you will be required to create the outer grid container with two or more inner blocks:

  1. Grid container: The grid container requires the CSS attribute ui-grid-* to configure the number of columns in the grid (see Table 6–1). For instance, to create a two-column grid we would set our grid CSS attribute to ui-grid-a.images
  2. Blocks: The blocks are contained within the grid. The blocks require the CSS attribute ui-block-* to identify its column position (see Table 6–2). For instance, if we had a two-column grid, our first block would be styled with CSS attribute ui-block-a and the second block would be styled with CSS attribute ui-block-b.images

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *