PageRenderTime 54ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/docs/widgets/table-reflow/index.php

https://github.com/Intai/go-jquery-mobile
PHP | 171 lines | 156 code | 13 blank | 2 comment | 3 complexity | 668fd592698186a6982d65c9dd699d56 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>Table: Reflow - 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>Table: Reflow <a href="http://api.jquerymobile.com/table-reflow/" 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 reflow table mode works by collapsing the table columns into a stacked presentation that looks like blocks of label/data pairs for each row.
  26. </p>
  27. <h2>Reflow basics</h2>
  28. <p>The reflow responsive table only requires a table with a <code>data-role=&quot;table&quot;</code> on the table element. There is no need to set the <code>data-mode</code> attribute since <code>reflow</code> is the default. Be sure to include <code>thead</code> and <code>tbody</code> elements in your table. This example also uses the preset responsive breakpoint, applied via the <code>ui-responsive</code> class.</p>
  29. <div data-demo-html="true">
  30. <table data-role="table" id="movie-table" data-mode="reflow" class="ui-responsive table-stroke">
  31. <thead>
  32. <tr>
  33. <th data-priority="1">Rank</th>
  34. <th data-priority="persist">Movie Title</th>
  35. <th data-priority="2">Year</th>
  36. <th data-priority="3"><abbr title="Rotten Tomato Rating">Rating</abbr></th>
  37. <th data-priority="4">Reviews</th>
  38. </tr>
  39. </thead>
  40. <tbody>
  41. <tr>
  42. <th>1</th>
  43. <td><a href="http://en.wikipedia.org/wiki/Citizen_Kane" data-rel="external">Citizen Kane</a></td>
  44. <td>1941</td>
  45. <td>100%</td>
  46. <td>74</td>
  47. </tr>
  48. <tr>
  49. <th>2</th>
  50. <td><a href="http://en.wikipedia.org/wiki/Casablanca_(film)" data-rel="external">Casablanca</a></td>
  51. <td>1942</td>
  52. <td>97%</td>
  53. <td>64</td>
  54. </tr>
  55. <tr>
  56. <th>3</th>
  57. <td><a href="http://en.wikipedia.org/wiki/The_Godfather" data-rel="external">The Godfather</a></td>
  58. <td>1972</td>
  59. <td>97%</td>
  60. <td>87</td>
  61. </tr>
  62. <tr>
  63. <th>4</th>
  64. <td><a href="http://en.wikipedia.org/wiki/Gone_with_the_Wind_(film)" data-rel="external">Gone with the Wind</a></td>
  65. <td>1939</td>
  66. <td>96%</td>
  67. <td>87</td>
  68. </tr>
  69. <tr>
  70. <th>5</th>
  71. <td><a href="http://en.wikipedia.org/wiki/Lawrence_of_Arabia_(film)" data-rel="external">Lawrence of Arabia</a></td>
  72. <td>1962</td>
  73. <td>94%</td>
  74. <td>87</td>
  75. </tr>
  76. <tr>
  77. <th>6</th>
  78. <td><a href="http://en.wikipedia.org/wiki/Dr._Strangelove" data-rel="external">Dr. Strangelove Or How I Learned to Stop Worrying and Love the Bomb</a></td>
  79. <td>1964</td>
  80. <td>92%</td>
  81. <td>74</td>
  82. </tr>
  83. <tr>
  84. <th>7</th>
  85. <td><a href="http://en.wikipedia.org/wiki/The_Graduate" data-rel="external">The Graduate</a></td>
  86. <td>1967</td>
  87. <td>91%</td>
  88. <td>122</td>
  89. </tr>
  90. <tr>
  91. <th>8</th>
  92. <td><a href="http://en.wikipedia.org/wiki/The_Wizard_of_Oz_(1939_film)" data-rel="external">The Wizard of Oz</a></td>
  93. <td>1939</td>
  94. <td>90%</td>
  95. <td>72</td>
  96. </tr>
  97. <tr>
  98. <th>9</th>
  99. <td><a href="http://en.wikipedia.org/wiki/Singin%27_in_the_Rain" data-rel="external">Singin' in the Rain</a></td>
  100. <td>1952</td>
  101. <td>89%</td>
  102. <td>85</td>
  103. </tr>
  104. <tr>
  105. <th>10</th>
  106. <td class="title"><a href="http://en.wikipedia.org/wiki/Inception" data-rel="external">Inception</a></td>
  107. <td>2010</td>
  108. <td>84%</td>
  109. <td>78</td>
  110. </tr>
  111. </tbody>
  112. </table>
  113. </div><!--/demo-html -->
  114. <h2>Making the table responsive</h2>
  115. <p>By default, a table with reflow mode will display the stacked presentation style on all screen widths. The styles to make the table responsive are added by applying a media query with rules to switch to the tabular style presentation above a specific screen width.</p>
  116. <p>This is done by wrapping a few simple CSS rules in and a media query that only applies the rules above a certain width breakpoint. The styles make the table header rows visible, display the cells in a tabular format, and hide the generated label elements within each. Here is an example media query that swaps the presentation at 40em (640 pixels): </p>
  117. <pre><code><strong>@media ( min-width: 40em ) {</strong>
  118. /* Show the table header rows and set all cells to display: table-cell */
  119. .my-custom-breakpoint td,
  120. .my-custom-breakpoint th,
  121. .my-custom-breakpoint tbody th,
  122. .my-custom-breakpoint tbody td,
  123. .my-custom-breakpoint thead td,
  124. .my-custom-breakpoint thead th {
  125. display: table-cell;
  126. margin: 0;
  127. }
  128. /* Hide the labels in each cell */
  129. .my-custom-breakpoint td .ui-table-cell-label,
  130. .my-custom-breakpoint th .ui-table-cell-label {
  131. display: none;
  132. }
  133. <strong>}</strong>
  134. </code></pre>
  135. <p>It's best to use a <code>class</code> on the table to apply the breakpoint. Add these rules to your custom stylesheet that is included in the <code>head</code> of the page. We recommend creating a set of custom breakpoint classes that can be used to apply standard table breakpoints in your project.</p>
  136. <h2>Choosing a breakpoint</h2>
  137. <p>The goal is to determine the minimum width at which the <em>entire table</em> will fit comfortably within the screen. Find this width by populating a table with realistic sample data, then adjust the browser window until the table completely fits and has a bit of extra space to account for rendering differences across devices. This is the natural place to set the breakpoint that switches between the stacked and tabular presentation modes. The breakpoint width is highly dependent on the number of columns in the table and content within each cell.</p>
  138. <h2>Applying a preset breakpoint</h2>
  139. <p>Even though we strongly encourage you to write custom breakpoints yourself, the framework includes a single pre-configured breakpoint that targets the stacked style to smaller phones and swaps to a tabular prsentation on larger phones, tablet and desktop devices. To use this preset breakpoint, add the <code>ui-responsive</code> class to the table to convert from the stacked presentation to a tabular presentation at 560px (35em). If this breakpoint doesn't work for your content, we encourage you to write a custom breakpoint as descibed above.</p>
  140. <pre><code>&lt;table data-role=&quot;table&quot; <strong>class=&quot;ui-responsive&quot;</strong>&gt;</code></pre>
  141. <p></p>
  142. <h2>Grouped column headers</h2>
  143. <p>It's fairly common to need to logically group multiple columns together under a heading group for financial or scientific data. The framework can support the most simple version of this by allowing for two rows of table headers (<code>TH</code>), with the first row containing simple <code>colspan</code> attributes to group the columns below. In this configuration, the framework will add a class to the label of the first cell in each group to allow you to style these differently and provide additional visual hierarchy. </p>
  144. </div><!-- /content -->
  145. <div data-role="footer" class="jqm-footer">
  146. <p class="jqm-version"></p>
  147. <p>Copyright 2013 The jQuery Foundation</p>
  148. </div><!-- /footer -->
  149. <?php include( '../../global-nav.php' ); ?>
  150. </div><!-- /page -->
  151. </body>
  152. </html>