layout-modes.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Layout modes &middot; Isotope Docs</title>
  6. <!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
  7. <link rel="stylesheet" href="../css/style.css" />
  8. <!-- scripts at bottom of page -->
  9. </head>
  10. <body class="docs option-def">
  11. <nav id="site-nav">
  12. <h1><a href="../index.html">Isotope</a></h1>
  13. <h2>Docs</h2>
  14. <ul>
  15. <li><a href="../docs/introduction.html">Introduction</a>
  16. <li><a href="../docs/options.html">Options</a>
  17. <li><a href="../docs/methods.html">Methods</a>
  18. <li class="current"><a href="#content">Layout modes</a>
  19. <ul class="toc">
  20. <li><a href="#cellsbycolumn">cellsByColumn</a></li>
  21. <li><a href="#cellsbyrow">cellsByRow</a></li>
  22. <li><a href="#fitcolumns">fitColumns</a></li>
  23. <li><a href="#fitrows">fitRows</a></li>
  24. <li><a href="#masonry">masonry</a></li>
  25. <li><a href="#masonryhorizontal">masonryHorizontal</a></li>
  26. <li><a href="#straightacross">straightAcross</a></li>
  27. <li><a href="#straightdown">straightDown</a></li>
  28. <li><a href="#horizontal_layouts">Horizontal layouts</a></li>
  29. <li><a href="#modified_layout_modes">Modified layout modes</a></li>
  30. </ul>
  31. </li>
  32. <li><a href="../docs/filtering.html">Filtering</a>
  33. <li><a href="../docs/sorting.html">Sorting</a>
  34. <li><a href="../docs/animating.html">Animating</a>
  35. <li><a href="../docs/adding-items.html">Adding items</a>
  36. <li><a href="../docs/extending-isotope.html">Extending Isotope</a>
  37. <li><a href="../docs/hash-history-jquery-bbq.html">Hash history with jQuery BBQ</a>
  38. <li><a href="../docs/help.html">Help</a>
  39. <li><a href="../docs/license.html">License</a>
  40. </ul>
  41. <h2>Demos</h2>
  42. <ul>
  43. <li><a href="../demos/basic.html">Basic</a>
  44. <li><a href="../demos/elements-complete.html">Elements Complete</a>
  45. <li><a href="../demos/elements-partial.html">Elements Partial</a>
  46. <li><a href="../demos/layout-modes.html">Layout modes</a>
  47. <li><a href="../demos/filtering.html">Filtering</a>
  48. <li><a href="../demos/sorting.html">Sorting</a>
  49. <li><a href="../demos/relayout.html">reLayout</a>
  50. <li><a href="../demos/adding-items.html">Adding items</a>
  51. <li><a href="../demos/infinite-scroll.html">Infinite Scroll</a>
  52. <li><a href="../demos/images.html">Images</a>
  53. <li><a href="../demos/combination-filters.html">Combination filters</a>
  54. <li><a href="../demos/hash-history.html">Hash history</a>
  55. <li><a href="../demos/fluid-responsive.html">Fluid / responsive</a>
  56. </ul>
  57. <h2>Custom layout modes</h2>
  58. <ul>
  59. <li><a href="../custom-layout-modes/centered-masonry.html">Centered Masonry</a>
  60. <li><a href="../custom-layout-modes/category-rows.html">Category rows</a>
  61. <li><a href="../custom-layout-modes/masonry-corner-stamp.html">Masonry corner stamp</a>
  62. <li><a href="../custom-layout-modes/masonry-gutters.html">Masonry gutters</a>
  63. <li><a href="../custom-layout-modes/spine-align.html">Spine align</a>
  64. </ul>
  65. <h2><a href="../tests/index.html">Tests</a></h2>
  66. </nav> <!-- #site-nav -->
  67. <section id="content">
  68. <h1>Layout modes</h1>
  69. <p>Isotope has a versatile layout engine that can accommodate multiple layout modes. You can set and change the layout mode via the <code>layoutMode</code> option.</p>
  70. <p><a href='../demos/layout-modes.html'><strong>See Demo: Layout modes</strong></a></p>
  71. <h3 id='example'>Example</h3>
  72. <div class='highlight'><pre><code class='javascript'><span class='nx'>$</span><span class='p'>(</span><span class='s1'>&#39;#container&#39;</span><span class='p'>).</span><span class='nx'>isotope</span><span class='p'>({</span> <span class='nx'>layoutMode</span> <span class='o'>:</span> <span class='s1'>&#39;fitRows&#39;</span> <span class='p'>});</span>
  73. </code></pre>
  74. </div>
  75. <p>Several layout modes are built into Isotope.</p>
  76. <h2 id='cellsbycolumn'>cellsByColumn</h2>
  77. <p>A grid layout where items are centered inside each cell. The grid is defined by two options, <code>columnWidth</code> and <code>rowHeight</code>. The horizontal equivalent of cellsByRow.</p>
  78. <h3 id='cellsByColumn-options'>Options</h3>
  79. <dl class='clearfix'>
  80. <dt><code>columnWidth</code></dt>
  81. <dd class='option-type'>Integer</dd>
  82. </dl><dl class='clearfix'>
  83. <dt><code>rowHeight</code></dt>
  84. <dd class='option-type'>Integer</dd>
  85. </dl>
  86. <h3 id='cellsByColumn-example'>Example</h3>
  87. <div class='highlight'><pre><code class='javascript'><span class='nx'>$</span><span class='p'>(</span><span class='s1'>&#39;#container&#39;</span><span class='p'>).</span><span class='nx'>isotope</span><span class='p'>({</span>
  88. <span class='nx'>layoutMode</span> <span class='o'>:</span> <span class='s1'>&#39;cellsByColumn&#39;</span><span class='p'>,</span>
  89. <span class='nx'>cellsByRow</span> <span class='o'>:</span> <span class='p'>{</span>
  90. <span class='nx'>columnWidth</span> <span class='o'>:</span> <span class='mi'>240</span><span class='p'>,</span>
  91. <span class='nx'>rowHeight</span> <span class='o'>:</span> <span class='mi'>360</span>
  92. <span class='p'>}</span>
  93. <span class='p'>});</span>
  94. </code></pre>
  95. </div>
  96. <h2 id='cellsbyrow'>cellsByRow</h2>
  97. <p>A grid layout where items are centered inside each cell. The grid is defined by two options, <code>columnWidth</code> and <code>rowHeight</code>.</p>
  98. <h3 id='cellsByRow-options'>Options</h3>
  99. <dl class='clearfix'>
  100. <dt><code>columnWidth</code></dt>
  101. <dd class='option-type'>Integer</dd>
  102. </dl><dl class='clearfix'>
  103. <dt><code>rowHeight</code></dt>
  104. <dd class='option-type'>Integer</dd>
  105. </dl>
  106. <h3 id='cellsByRow-example'>Example</h3>
  107. <div class='highlight'><pre><code class='javascript'><span class='nx'>$</span><span class='p'>(</span><span class='s1'>&#39;#container&#39;</span><span class='p'>).</span><span class='nx'>isotope</span><span class='p'>({</span>
  108. <span class='nx'>layoutMode</span> <span class='o'>:</span> <span class='s1'>&#39;cellsByRow&#39;</span><span class='p'>,</span>
  109. <span class='nx'>cellsByRow</span> <span class='o'>:</span> <span class='p'>{</span>
  110. <span class='nx'>columnWidth</span> <span class='o'>:</span> <span class='mi'>240</span><span class='p'>,</span>
  111. <span class='nx'>rowHeight</span> <span class='o'>:</span> <span class='mi'>360</span>
  112. <span class='p'>}</span>
  113. <span class='p'>});</span>
  114. </code></pre>
  115. </div>
  116. <h2 id='fitcolumns'>fitColumns</h2>
  117. <p>Item elements are arranged into columns. The horizontal equivalent of fitRows. Columns progress from left to right. Items within those columns are arranged top-to-bottom.</p>
  118. <h2 id='fitrows'>fitRows</h2>
  119. <p>Item elements are arranged into rows, left to right. Rows progress top to bottom. Similar to what you would expect from a layout that uses <code>float: left</code>.</p>
  120. <h2 id='masonry'>masonry</h2>
  121. <p>masonry is the default layout mode for Isotope. Item elements are arranged intelligently within a grid. For each item element, the script calculates the next best fit for the item within the grid.</p>
  122. <h3 id='masonry-options'>Options</h3>
  123. <dl class='clearfix'>
  124. <dt><code>columnWidth</code></dt>
  125. <dd class='option-type'>Integer</dd>
  126. </dl>
  127. <p>The width of one column in the grid. If no value is set for <code>columnWidth</code>, default is the width of the first item element.</p>
  128. <h3 id='masonry-example'>Example</h3>
  129. <div class='highlight'><pre><code class='javascript'><span class='nx'>$</span><span class='p'>(</span><span class='s1'>&#39;#container&#39;</span><span class='p'>).</span><span class='nx'>isotope</span><span class='p'>({</span>
  130. <span class='nx'>masonry</span> <span class='o'>:</span> <span class='p'>{</span>
  131. <span class='nx'>columnWidth</span> <span class='o'>:</span> <span class='mi'>240</span>
  132. <span class='p'>}</span>
  133. <span class='p'>});</span>
  134. </code></pre>
  135. </div>
  136. <h2 id='masonryhorizontal'>masonryHorizontal</h2>
  137. <p>The horizontal equivalent of masonry layout. Instead of progressing top-to-bottom, masonryHorizontal layout will progress left-to-right. Item elements are arranged intelligently within a grid. For each item element, the script calculates the next best fit for the item within the grid.</p>
  138. <h3 id='masonryHorizontal-options'>Options</h3>
  139. <dl class='clearfix'>
  140. <dt><code>rowHeight</code></dt>
  141. <dd class='option-type'>Integer</dd>
  142. </dl>
  143. <p>The width of one column in the grid. If no value is set for <code>rowHeight</code>, default is the height of the first item element.</p>
  144. <h3 id='masonryHorizontal-example'>Example</h3>
  145. <div class='highlight'><pre><code class='javascript'><span class='nx'>$</span><span class='p'>(</span><span class='s1'>&#39;#container&#39;</span><span class='p'>).</span><span class='nx'>isotope</span><span class='p'>({</span>
  146. <span class='nx'>masonryHorizontal</span> <span class='o'>:</span> <span class='p'>{</span>
  147. <span class='nx'>rowHeight</span> <span class='o'>:</span> <span class='mi'>360</span>
  148. <span class='p'>}</span>
  149. <span class='p'>});</span>
  150. </code></pre>
  151. </div>
  152. <h2 id='straightacross'>straightAcross</h2>
  153. <p>Item elements are arranged horizontally left to right. Useful for simple lists.</p>
  154. <h2 id='straightdown'>straightDown</h2>
  155. <p>Item elements are arranged vertically top to bottom. Useful for simple lists.</p>
  156. <h2 id='horizontal_layouts'>Horizontal layouts</h2>
  157. <p>Horizontal layout modes (masonryHorizontal, fitColumns, cellsByColumn, and straightAcross) need a container that has a height value. Be sure that your CSS has height set.</p>
  158. <div class='highlight'><pre><code class='css'><span class='nf'>#container</span> <span class='p'>{</span>
  159. <span class='c'>/* either of these will work for horizontal Isotope layouts */</span>
  160. <span class='k'>height</span><span class='o'>:</span> <span class='m'>80</span><span class='o'>%</span><span class='p'>;</span>
  161. <span class='k'>height</span><span class='o'>:</span> <span class='m'>480px</span><span class='p'>;</span>
  162. <span class='p'>}</span>
  163. </code></pre>
  164. </div>
  165. <h2 id='modified_layout_modes'>Modified layout modes</h2>
  166. <p><a href='extending-isotope.html'>Isotope&#8217;s methods can be extended and overwritten</a> to shim-in additional functionality. See these modified layout modes:</p>
  167. <ul>
  168. <li><a href='../custom-layout-modes/centered-masonry.html'><strong>Centered masonry</strong></a></li>
  169. <li><a href='../custom-layout-modes/masonry-corner-stamp.html'><strong>Masonry corner stamp</strong></a></li>
  170. <li><a href='../custom-layout-modes/masonry-gutters.html'><strong>Masonry gutters</strong></a></li>
  171. </ul>
  172. <p>To use these mods, copy the revised methods found in the demos&#8217; page source. They look like:</p>
  173. <div class='highlight'><pre><code class='javascript'><span class='nx'>$</span><span class='p'>.</span><span class='nx'>Isotope</span><span class='p'>.</span><span class='nx'>prototype</span><span class='p'>.</span><span class='nx'>_masonryReset</span> <span class='o'>=</span> <span class='kd'>function</span><span class='p'>()</span> <span class='p'>{</span>
  174. <span class='c1'>// modified code..</span>
  175. <span class='p'>};</span>
  176. </code></pre>
  177. </div>
  178. <footer>
  179. Isotope by <a href="http://desandro.com">David DeSandro</a> / <a href="http://metafizzy.co">Metafizzy</a>
  180. </footer>
  181. </section> <!-- #content -->
  182. </body>
  183. </html>