mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-17 06:20:26 +00:00
This makes our include model match the include model on the CDN, and allows devs to make use of mobileinit for debugging some of the samples since that must be set up after jquery.js, but before jquery-mobile.
141 lines
No EOL
7.7 KiB
HTML
Executable file
141 lines
No EOL
7.7 KiB
HTML
Executable file
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>jQuery Mobile Docs - Content formatting</title>
|
|
<link rel="stylesheet" href="../../themes/default/" />
|
|
<link rel="stylesheet" href="../_assets/css/jqm-docs.css"/>
|
|
<script type="text/javascript" src="../../js/jquery.js"></script>
|
|
<script type="text/javascript" src="../../js/"></script>
|
|
<script type="text/javascript" src="../docs/docs.js"></script>
|
|
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<div data-role="page">
|
|
|
|
<div data-role="header">
|
|
<h1>Layout grids</h1>
|
|
</div><!-- /header -->
|
|
|
|
<div data-role="content">
|
|
|
|
<p>Using multiple column layouts isn't generally recommended on a mobile device because of the narrow screen width, but there are times where you may need to place small elements side-by-side (like buttons or navigation tabs, for example). </p>
|
|
|
|
<p>The jQuery Mobile framework provides a simple way to build CSS-based columns through a block style class convention called <code>ui-grid</code>. </p>
|
|
<p>There are two preset configurations layouts — two-column (using the <code>class</code> of <code>ui-grid-a</code>), and three-column (using the <code>class</code> of <code>ui-grid-b</code>) — that can be used in any situation that requires columns. Grids are 100% width, completely invisible (no borders or backgrounds) and don't have padding or margins, so they shouldn't interfere with the styles of elements placed inside them.</p>
|
|
|
|
<h2>Two column grids</h2>
|
|
<p>To build a two-column (50/50%) layout, start with a container with a <code>class</code> of <code>ui-grid-a</code>, and add two child containers inside it classed with <code>ui-block-a</code> for the first column and <code>ui-block-b</code> for the second:</p>
|
|
|
|
<pre><code>
|
|
<div class="ui-grid-a">
|
|
<div class="ui-block-a"><strong>I'm Block A</strong> and text inside will wrap</div>
|
|
<div class="ui-block-b"><strong>I'm Block B</strong> and text inside will wrap</div>
|
|
</div><!-- /grid-a -->
|
|
</code></pre>
|
|
|
|
|
|
|
|
<p>The above markup produces the following content layout:</p>
|
|
|
|
<div class="ui-grid-a">
|
|
<div class="ui-block-a"><strong>I'm Block A</strong> and text inside will wrap.</div>
|
|
<div class="ui-block-b"><strong>I'm Block B</strong> and text inside will wrap.</div>
|
|
</div><!-- /grid-a -->
|
|
|
|
<p>As you see above, by default grid blocks have no styles for appearance; they simply present content side-by-side.</p>
|
|
|
|
<p>Grid classes can be applied to any container. In this next example, we add <code>ui-grid-a</code> to a <code>fieldset</code>, and apply the <code>ui-block</code> classes to the two buttons inside to stretch them each to 50% of the screen width:</p>
|
|
|
|
<pre><code>
|
|
<fieldset class="ui-grid-a">
|
|
<div class="ui-block-a"><button type="submit" data-theme="c">Cancel</button></div>
|
|
<div class="ui-block-b"><button type="submit" data-theme="b">Submit</button></div>
|
|
</fieldset>
|
|
</code></pre>
|
|
|
|
<fieldset class="ui-grid-a">
|
|
<div class="ui-block-a"><button type="submit" data-theme="c">Cancel</button></div>
|
|
<div class="ui-block-b"><button type="submit" data-theme="b">Submit</button></div>
|
|
</fieldset>
|
|
|
|
|
|
<p>And, grid blocks can adopt presentation styles from the <a href="../themes/index.html">theming system</a> — by adding a height and color swatch reference to the grid blocks, we can achieve this style appearance:</p>
|
|
|
|
<div class="ui-grid-a">
|
|
<div class="ui-block-a"><div class="ui-bar ui-bar-e" style="height:120px">Block A</div></div>
|
|
<div class="ui-block-b"><div class="ui-bar ui-bar-e" style="height:120px">Block B</div></div>
|
|
</div><!-- /grid-a -->
|
|
|
|
<h2>Three-column grids</h2>
|
|
<p>The other grid layout configuration uses <code>class=ui-grid-b</code> on the parent, and 3 child container elements, each with its respective <code>ui-block-a/b/c</code> class, to create a three-column layout (33/33/33%).</p>
|
|
|
|
<pre><code>
|
|
<div class="ui-grid-b">
|
|
<div class="ui-block-a">Block A</div>
|
|
<div class="ui-block-b">Block B</div>
|
|
<div class="ui-block-c">Block C</div>
|
|
</div><!-- /grid-a -->
|
|
</code></pre>
|
|
|
|
<p>This will produce a 33/33/33% grid for our content.</p>
|
|
|
|
<div class="ui-grid-b">
|
|
<div class="ui-block-a"><div class="ui-bar ui-bar-e" style="height:120px">Block A</div></div>
|
|
<div class="ui-block-b"><div class="ui-bar ui-bar-e" style="height:120px">Block B</div></div>
|
|
<div class="ui-block-c"><div class="ui-bar ui-bar-e" style="height:120px">Block C</div></div>
|
|
</div><!-- /grid-b -->
|
|
|
|
<p>And an example of a 3 column grid with buttons inside:</p>
|
|
|
|
<fieldset class="ui-grid-b">
|
|
<div class="ui-block-a"><button type="submit" data-theme="c">Hmm</button></div>
|
|
<div class="ui-block-b"><button type="submit" data-theme="a">No</button></div>
|
|
<div class="ui-block-b"><button type="submit" data-theme="b">Yes</button></div>
|
|
</fieldset>
|
|
|
|
<h2>Four-column grids</h2>
|
|
|
|
<p>A four-column, 25/25/25/25% grid is created by specifying <code>class=ui-grid-c</code> on the parent and adding a fourth block.</p>
|
|
|
|
<div class="ui-grid-c">
|
|
<div class="ui-block-a"><div class="ui-bar ui-bar-e" style="height:120px">A</div></div>
|
|
<div class="ui-block-b"><div class="ui-bar ui-bar-e" style="height:120px">B</div></div>
|
|
<div class="ui-block-c"><div class="ui-bar ui-bar-e" style="height:120px">C</div></div>
|
|
<div class="ui-block-d"><div class="ui-bar ui-bar-e" style="height:120px">D</div></div>
|
|
</div><!-- /grid-c -->
|
|
|
|
<h2>Five-column grids</h2>
|
|
<p>A five-column, 20/20/20/20/20% grid is created by specifying <code>class=ui-grid-d</code> on the parent and adding a fourth block.</p>
|
|
|
|
<div class="ui-grid-d">
|
|
<div class="ui-block-a"><div class="ui-bar ui-bar-e" style="height:120px">A</div></div>
|
|
<div class="ui-block-b"><div class="ui-bar ui-bar-e" style="height:120px">B</div></div>
|
|
<div class="ui-block-c"><div class="ui-bar ui-bar-e" style="height:120px">C</div></div>
|
|
<div class="ui-block-d"><div class="ui-bar ui-bar-e" style="height:120px">D</div></div>
|
|
<div class="ui-block-e"><div class="ui-bar ui-bar-e" style="height:120px">E</div></div>
|
|
</div><!-- /grid-c -->
|
|
|
|
<h2>Multiple row grids</h2>
|
|
|
|
<p>Grids are designed to wrap to multiple rows of items. For example, if you specify a 3-column grid (ui-grid-b) on a container that has nine child blocks, it will wrap to 3 rows of 3 items each. There is a CSS rule to clear the floats and start a new line when the <code>class=ui-block-a</code> is seen so make sure to assign block classes in a repeating sequence (a, b, c, a, b, c, etc.) that maps to the grid type:</p>
|
|
|
|
<div class="ui-grid-b">
|
|
<div class="ui-block-a"><div class="ui-bar ui-bar-e" style="height:120px">A</div></div>
|
|
<div class="ui-block-b"><div class="ui-bar ui-bar-e" style="height:120px">B</div></div>
|
|
<div class="ui-block-c"><div class="ui-bar ui-bar-e" style="height:120px">C</div></div>
|
|
<div class="ui-block-a"><div class="ui-bar ui-bar-e" style="height:120px">A</div></div>
|
|
<div class="ui-block-b"><div class="ui-bar ui-bar-e" style="height:120px">B</div></div>
|
|
<div class="ui-block-c"><div class="ui-bar ui-bar-e" style="height:120px">C</div></div>
|
|
<div class="ui-block-a"><div class="ui-bar ui-bar-e" style="height:120px">A</div></div>
|
|
<div class="ui-block-b"><div class="ui-bar ui-bar-e" style="height:120px">B</div></div>
|
|
<div class="ui-block-c"><div class="ui-bar ui-bar-e" style="height:120px">C</div></div>
|
|
</div><!-- /grid-c -->
|
|
|
|
</div><!-- /content -->
|
|
</div><!-- /page -->
|
|
|
|
</body>
|
|
</html> |