PageRenderTime 63ms CodeModel.GetById 32ms RepoModel.GetById 1ms app.codeStats 0ms

/demos/widgets/grids/index.php

https://github.com/BradBroulik/jquery-mobile
PHP | 221 lines | 193 code | 27 blank | 1 comment | 3 complexity | d2a356f5a4cd2be9bf895b0fb4d14191 MD5 | raw file
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>Grids - jQuery Mobile Demos</title>
  7. <link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css">
  8. <link rel="stylesheet" href="../../_assets/css/jqm-demos.css">
  9. <link rel="shortcut icon" href="../../favicon.ico">
  10. <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,700">
  11. <script src="../../../js/jquery.js"></script>
  12. <script src="../../_assets/js/"></script>
  13. <script src="../../../js/"></script>
  14. </head>
  15. <body>
  16. <div data-role="page" class="jqm-demos" data-quicklinks="true">
  17. <div data-role="header" class="jqm-header">
  18. <h1 class="jqm-logo"><a href="../../"><img src="../../_assets/img/jquery-logo.png" alt="jQuery Mobile Framework"></a></h1>
  19. <a href="#" class="jqm-navmenu-link" data-icon="bars" data-iconpos="notext">Navigation</a>
  20. <a href="#" class="jqm-search-link" data-icon="search" data-iconpos="notext">Search</a>
  21. <?php include( '../../search.php' ); ?>
  22. </div><!-- /header -->
  23. <div data-role="content" class="jqm-content">
  24. <h1>Grids <a href="http://api.jquerymobile.com/grid-layout/" data-ajax="false" data-role="button" data-inline="true" data-mini="true" data-icon="arrow-r" data-iconpos="right" class="jqm-api-link">API</a></h1>
  25. <p class="jqm-intro">The jQuery Mobile framework provides a simple way to build CSS-based columns that can also be responsive.
  26. </p>
  27. <h2>Grid basics</h2>
  28. <p>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. Within the grid container, child elements are assigned <code>ui-block-a/b/c/d/e</code> in a sequential manner which makes each "block" element float side-by-side, forming the grid.</p>
  29. <h2>Two column grids</h2>
  30. <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. On the blocks below, we're adding two classes: <code>ui-bar</code> to add the default bar padding and <code>ui-bar-e</code> to apply the background gradient and font styling for the "e" toolbar theme swatch. For illustration purposes, an inline <code>style="height:120px"</code> attribute is also added to each grid to set each to a standard height. </p>
  31. <div data-demo-html="true">
  32. <div class="ui-grid-a">
  33. <div class="ui-block-a"><div class="ui-bar ui-bar-e" style="height:60px">Block A</div></div>
  34. <div class="ui-block-b"><div class="ui-bar ui-bar-e" style="height:60px">Block B</div></div>
  35. </div><!-- /grid-a -->
  36. </div><!--/demo-html -->
  37. <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 container of each of the two buttons inside to stretch them each to 50% of the screen width:</p>
  38. <div data-demo-html="true">
  39. <fieldset class="ui-grid-a">
  40. <div class="ui-block-a"><button type="submit" data-theme="c">Cancel</button></div>
  41. <div class="ui-block-b"><button type="submit" data-theme="b">Submit</button></div>
  42. </fieldset>
  43. </div><!--/demo-html -->
  44. <h2>Three-column grids</h2>
  45. <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>
  46. <div data-demo-html="true">
  47. <div class="ui-grid-b">
  48. <div class="ui-block-a"><div class="ui-bar ui-bar-e" style="height:60px">Block A</div></div>
  49. <div class="ui-block-b"><div class="ui-bar ui-bar-e" style="height:60px">Block B</div></div>
  50. <div class="ui-block-c"><div class="ui-bar ui-bar-e" style="height:60px">Block C</div></div>
  51. </div><!-- /grid-b -->
  52. </div><!--/demo-html -->
  53. <p>And an example of a 3 column grid with buttons inside:</p>
  54. <div data-demo-html="true">
  55. <fieldset class="ui-grid-b">
  56. <div class="ui-block-a"><button type="submit" data-theme="c">Hmm</button></div>
  57. <div class="ui-block-b"><button type="submit" data-theme="a">No</button></div>
  58. <div class="ui-block-c"><button type="submit" data-theme="b">Yes</button></div>
  59. </fieldset>
  60. </div><!--/demo-html -->
  61. <p>View more examples of <a href="grid-buttons.php" data-ajax="false">buttons in grids</a>.</p>
  62. <h2>Four-column grids</h2>
  63. <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>
  64. <div data-demo-html="true">
  65. <div class="ui-grid-c">
  66. <div class="ui-block-a"><div class="ui-bar ui-bar-e" style="height:60px">A</div></div>
  67. <div class="ui-block-b"><div class="ui-bar ui-bar-e" style="height:60px">B</div></div>
  68. <div class="ui-block-c"><div class="ui-bar ui-bar-e" style="height:60px">C</div></div>
  69. <div class="ui-block-d"><div class="ui-bar ui-bar-e" style="height:60px">D</div></div>
  70. </div><!-- /grid-c -->
  71. </div><!--/demo-html -->
  72. <h2>Five-column grids</h2>
  73. <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 fifth block. </p>
  74. <div data-demo-html="true">
  75. <div class="ui-grid-d">
  76. <div class="ui-block-a"><div class="ui-bar ui-bar-e" style="height:60px">A</div></div>
  77. <div class="ui-block-b"><div class="ui-bar ui-bar-e" style="height:60px">B</div></div>
  78. <div class="ui-block-c"><div class="ui-bar ui-bar-e" style="height:60px">C</div></div>
  79. <div class="ui-block-d"><div class="ui-bar ui-bar-e" style="height:60px">D</div></div>
  80. <div class="ui-block-e"><div class="ui-bar ui-bar-e" style="height:60px">E</div></div>
  81. </div><!-- /grid-c -->
  82. </div><!--/demo-html -->
  83. <h2>Multiple row grids</h2>
  84. <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>
  85. <div data-demo-html="true">
  86. <div class="ui-grid-b">
  87. <div class="ui-block-a"><div class="ui-bar ui-bar-e" style="height:60px">A</div></div>
  88. <div class="ui-block-b"><div class="ui-bar ui-bar-e" style="height:60px">B</div></div>
  89. <div class="ui-block-c"><div class="ui-bar ui-bar-e" style="height:60px">C</div></div>
  90. <div class="ui-block-a"><div class="ui-bar ui-bar-e" style="height:60px">A</div></div>
  91. <div class="ui-block-b"><div class="ui-bar ui-bar-e" style="height:60px">B</div></div>
  92. <div class="ui-block-c"><div class="ui-bar ui-bar-e" style="height:60px">C</div></div>
  93. <div class="ui-block-a"><div class="ui-bar ui-bar-e" style="height:60px">A</div></div>
  94. <div class="ui-block-b"><div class="ui-bar ui-bar-e" style="height:60px">B</div></div>
  95. <div class="ui-block-c"><div class="ui-bar ui-bar-e" style="height:60px">C</div></div>
  96. </div><!-- /grid-c -->
  97. </div><!--/demo-html -->
  98. <h2>Grid solo class</h2>
  99. <p>The framework adds left and right margin to buttons in a grid. For a single button you can use a container with class <code>ui-grid-solo</code> and wrap the button in a div with class <code>ui-block-a</code> like the example below. This way the button will get the same margin. View more examples of <a href="grid-buttons.php" data-ajax="false">buttons in grids</a>.</p>
  100. <div data-demo-html="true">
  101. <div class="ui-grid-a">
  102. <div class="ui-block-a"><button type="button" data-theme="c">Previous</button></div>
  103. <div class="ui-block-b"><button type="button" data-theme="c">Next</button></div>
  104. </div>
  105. <div class="ui-grid-solo">
  106. <div class="ui-block-a"><button type="button" data-theme="b">More</button></div>
  107. </div>
  108. </div><!--/demo-html -->
  109. <h2>Responsive grids</h2>
  110. <p>It's straightforward to take the standard grids and make them responsive by stacking the grid blocks at narrow widths. Since we just want to override the floats and widths of the standard grid styles <em>below</em> a single breakpoint, use a <code>max-width</code> breakpoint to only apply the stacked styling as an override.</p>
  111. <p>We recommend adding a class (ex: <code>my-breakpoint</code>) to scope the styles for the media query so it can be applied selectively. From this basic start, you can customize the appearance further or even add additional breakpoints. See an example of a <a href="grid-custom.php" data-ajax="false">custom responsive grid</a>.</p>
  112. <pre><code>
  113. /* stack all grids below 40em (640px) */
  114. <strong>@media all and (max-width: 35em) {</strong>
  115. .my-breakpoint .ui-block-a,
  116. .my-breakpoint .ui-block-b,
  117. .my-breakpoint .ui-block-c,
  118. .my-breakpoint .ui-block-d,
  119. .my-breakpoint .ui-block-e {
  120. width: 100%;
  121. float: none;
  122. }
  123. <strong>}</strong>
  124. </code></pre>
  125. <h2>Breakpoint preset</h2>
  126. <p>To apply a preset breakpoint to stack grids below 35em (560px), add the <code>.ui-responsive</code> class to the grid container.</p>
  127. <!-- view source utilty wrapper -->
  128. <div data-demo-html="true" data-demo-css="true">
  129. <h3>Grid A (50/50)</h3>
  130. <div class="ui-grid-a ui-responsive">
  131. <div class="ui-block-a"><div class="ui-body ui-body-d">Block A</div></div>
  132. <div class="ui-block-b"><div class="ui-body ui-body-d">Block B</div></div>
  133. </div><!-- /grid-a -->
  134. <h3>Grid B (33/33/33)</h3>
  135. <div class="ui-grid-b ui-responsive">
  136. <div class="ui-block-a"><div class="ui-body ui-body-d">Block A</div></div>
  137. <div class="ui-block-b"><div class="ui-body ui-body-d">Block B</div></div>
  138. <div class="ui-block-c"><div class="ui-body ui-body-d">Block C</div></div>
  139. </div><!-- /grid-b -->
  140. <h3>Grid C (25/25/25/25)</h3>
  141. <div class="ui-grid-c ui-responsive">
  142. <div class="ui-block-a"><div class="ui-body ui-body-d">A</div></div>
  143. <div class="ui-block-b"><div class="ui-body ui-body-d">B</div></div>
  144. <div class="ui-block-c"><div class="ui-body ui-body-d">C</div></div>
  145. <div class="ui-block-d"><div class="ui-body ui-body-d">D</div></div>
  146. </div><!-- /grid-c -->
  147. <h3>Grid D (20/20/20/20/20)</h3>
  148. <div class="ui-grid-d ui-responsive">
  149. <div class="ui-block-a"><div class="ui-body ui-body-d">A</div></div>
  150. <div class="ui-block-b"><div class="ui-body ui-body-d">B</div></div>
  151. <div class="ui-block-c"><div class="ui-body ui-body-d">C</div></div>
  152. <div class="ui-block-d"><div class="ui-body ui-body-d">D</div></div>
  153. <div class="ui-block-e"><div class="ui-body ui-body-d">E</div></div>
  154. </div><!-- /grid-d -->
  155. </div><!-- /data-demo -->
  156. </div><!-- /content -->
  157. <div data-role="footer" class="jqm-footer">
  158. <p class="jqm-version"></p>
  159. <p>Copyright 2013 The jQuery Foundation</p>
  160. </div><!-- /footer -->
  161. <?php include( '../../global-nav.php' ); ?>
  162. </div><!-- /page -->
  163. </body>
  164. </html>