Skip to content

Commit 0c880eb

Browse files
committed
Adds flexbox cols/rows
1 parent 6a0f336 commit 0c880eb

2 files changed

Lines changed: 791 additions & 497 deletions

File tree

demo.html

Lines changed: 196 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
pre { padding: 1em; background-color: #f3f3f3; }
1919
a:link, a:visited { color: #4e7ac7; }
2020
.demo { margin-bottom: 2em; }
21-
.demo > div { background-color: #4e7ac7; color: #fff; padding: 0.5em; text-align: center; }
21+
.demo > div { background-color: #4e7ac7; color: #fff; border: 1px dashed rgba(255, 255, 255, 0.2); padding: 1em; text-align: center; box-shadow: rgba(78, 122, 199, 0.5) 0 0 10px; }
2222
.demo.alt > div:nth-child(odd) { background-color: #2b4470; }
2323
.demo .demo > div { background-color: #9bb4e0; }
2424
.dashed { border: 1px dashed #ccc; }
@@ -47,7 +47,6 @@ <h1>CSS Grid demo / docs</h1>
4747
<li><a href="#layout">Grid layout</a></li>
4848
<li><a href="#responsive">Responsive breakpoints</a></li>
4949
<li><a href="#alignment">Aligning grid elements</a></li>
50-
<li><a href="#gap-spacing">Gap spacing</a></li>
5150
<li><a href="#offset">Offset grid elements</a></li>
5251
<li><a href="#nesting">Nesting grid elements</a></li>
5352
<li><a href="#ordering">Ordering grid elements</a></li>
@@ -184,7 +183,7 @@ <h3>Explicit columns</h3>
184183

185184
<h3>Implicit rows</h3>
186185

187-
<p>Implicit uniform rows can define their values at the parent grid element using <code>grid-rows-X</code></p>
186+
<p>Implicit uniform rows can define their values at the parent grid element using <code>grid-rows-X</code>.</p>
188187

189188
<div data-layout="grid-rows-3" class="demo" style="height: 350px;">
190189
<div>3</div>
@@ -200,7 +199,7 @@ <h3>Implicit rows</h3>
200199

201200
<h3>Explicit rows</h3>
202201

203-
<p>Rows that are not uniform can define their row span value directly on the element using <code>rows-X</code></p>
202+
<p>Rows that are not uniform can define their row span value directly on the element using <code>rows-X</code>.</p>
204203

205204
<div data-layout="grid-rows" class="demo" style="height: 350px;">
206205
<div data-layout="rows-1">1</div>
@@ -247,25 +246,25 @@ <h2>Responsive breakpoints</h2>
247246
</tr>
248247
<tr>
249248
<td><code>cols-1-sm</code> to <code>cols-12-sm</code><br><code>rows-1-sm</code> to <code>rows-12-sm</code></td>
250-
<td>Small devices (480px)</td>
249+
<td>Small devices (48em)</td>
251250
<td>Phones / Tablets</td>
252251
<td>100% width to start, column width at breakpoint.<br>100% height to start, row height at breakpoint.</td>
253252
</tr>
254253
<tr>
255254
<td><code>cols-1-md</code> to <code>cols-12-md</code><br><code>rows-1-md</code> to <code>rows-12-md</code>.</td>
256-
<td>Medium devices (720px)</td>
255+
<td>Medium devices (64em)</td>
257256
<td>Tablets / Laptops</td>
258257
<td>100% width to start, column width at breakpoint.<br>100% height to start, row height at breakpoint.</td>
259258
</tr>
260259
<tr>
261260
<td><code>cols-1-lg</code> to <code>cols-12-lg</code><br><code>rows-1-lg</code> to <code>rows-12-lg</code></td>
262-
<td>Large devices (960px)</td>
261+
<td>Large devices (75em)</td>
263262
<td>Tablets / Laptops</td>
264263
<td>100% width to start, column width at breakpoint.<br>100% height to start, row height at breakpoint.</td>
265264
</tr>
266265
<tr>
267266
<td><code>cols-1-xl</code> to <code>cols-12-xl</code><br><code>rows-1-xl</code> to <code>rows-12-xl</code></td>
268-
<td>Extra large devices (1440px)</td>
267+
<td>Extra large devices (86em)</td>
269268
<td>Hi-res Laptop / Desktop</td>
270269
<td>100% width to start, column width at breakpoint.<br>100% height to start, row height at breakpoint.</td>
271270
</tr>
@@ -395,80 +394,6 @@ <h3>Vertically bottom align columns</h3>
395394
</section>
396395

397396

398-
<section id="gap-spacing">
399-
400-
<div data-layout="grid-cols-2">
401-
<div data-layout="text-right last">
402-
<a href="#nav">Back to top</a>
403-
</div>
404-
<h2>Gap spacing</h2>
405-
</div>
406-
407-
<p>With special modifiers you can remove gap (gutter) in grid layouts.</p>
408-
409-
<ul>
410-
<li><code>gap-none</code>, <code>gap-none-sm</code>, <code>gap-none-md</code>, <code>gap-none-lg</code>, <code>gap-none-xl</code></li>
411-
<li><code>gap-cols-none</code>, <code>gap-cols-none-sm</code>, <code>gap-cols-none-md</code>, <code>gap-cols-none-lg</code>, <code>gap-cols-none-xl</code></li>
412-
<li><code>gap-rows-none</code>, <code>gap-rows-none-sm</code>, <code>gap-rows-none-md</code>, <code>gap-rows-none-lg</code>, <code>gap-rows-none-xl</code></li>
413-
</ul>
414-
415-
<div data-layout="grid-cols-3 gap-none" class="demo">
416-
<div>A</div>
417-
<div>B</div>
418-
<div>C</div>
419-
<div>D</div>
420-
<div>E</div>
421-
<div>F</div>
422-
</div>
423-
424-
<div data-layout="grid-cols-3 gap-cols-none" class="demo">
425-
<div>A</div>
426-
<div>B</div>
427-
<div>C</div>
428-
<div>D</div>
429-
<div>E</div>
430-
<div>F</div>
431-
</div>
432-
433-
<div data-layout="grid-cols-3 gap-rows-none" class="demo">
434-
<div>A</div>
435-
<div>B</div>
436-
<div>C</div>
437-
<div>D</div>
438-
<div>E</div>
439-
<div>F</div>
440-
</div>
441-
442-
<pre>&lt;div data-layout=&quot;grid-cols-3 gap-none&quot;&gt;
443-
&lt;div&gt;A&lt;/div&gt;
444-
&lt;div&gt;B&lt;/div&gt;
445-
&lt;div&gt;C&lt;/div&gt;
446-
&lt;div&gt;D&lt;/div&gt;
447-
&lt;div&gt;E&lt;/div&gt;
448-
&lt;div&gt;F&lt;/div&gt;
449-
&lt;/div&gt;
450-
451-
&lt;div data-layout=&quot;grid-cols-3 gap-cols-none&quot;&gt;
452-
&lt;div&gt;A&lt;/div&gt;
453-
&lt;div&gt;B&lt;/div&gt;
454-
&lt;div&gt;C&lt;/div&gt;
455-
&lt;div&gt;D&lt;/div&gt;
456-
&lt;div&gt;E&lt;/div&gt;
457-
&lt;div&gt;F&lt;/div&gt;
458-
&lt;/div&gt;
459-
460-
&lt;div data-layout=&quot;grid-cols-3 gap-rows-none&quot;&gt;
461-
&lt;div&gt;A&lt;/div&gt;
462-
&lt;div&gt;B&lt;/div&gt;
463-
&lt;div&gt;C&lt;/div&gt;
464-
&lt;div&gt;D&lt;/div&gt;
465-
&lt;div&gt;E&lt;/div&gt;
466-
&lt;div&gt;F&lt;/div&gt;
467-
&lt;/div&gt;</pre>
468-
469-
</section>
470-
471-
472397
<section id="offset">
473398

474399
<div data-layout="grid-cols-2">
@@ -676,36 +601,200 @@ <h3>Vertical and horizontal column centering</h3>
676601
<h2>Flex, Fit &amp; Fill</h2>
677602
</div>
678603

679-
<p>The <code>flex</code>, <code>fill</code> and <code>fit</code> attributes can be used to align variable size elements. Example use the <code>flex</code> attribute to set all immediate children to flex items. Once set use <code>fit</code> to adjust element to fit only to its content size and use <code>fill</code> to fill in all available space.</p>
604+
<h3>Flex implicit columns</h3>
605+
606+
<p>Implicit uniform columns can define their values at the parent flex element using <code>flex-cols-X</code>. There is no need for wrapper elements around each row, see <code>flex-cols-2</code> example below.</p>
680607

681608
<ul>
682-
<li><code>flex</code></li>
683-
<li><code>fit</code>, <code>fit-sm</code>, <code>fit-md</code>, <code>fit-lg</code>, <code>fit-xl</code></li>
684-
<li><code>fill</code>, <code>fill-sm</code>, <code>fill-md</code>, <code>fill-lg</code>, <code>fill-xl</code></li>
609+
<li><code>flex-cols-X</code>, <code>flex-cols-X-sm</code>, <code>flex-cols-X-md</code>, <code>flex-cols-X-lg</code>, <code>flex-cols-X-xl</code></li>
685610
</ul>
686611

687-
<div data-layout="flex" class="demo alt">
688-
<div data-layout="fit">
689-
<div>&lt;</div>
690-
</div>
691-
<div data-layout="fill">
692-
<div>Ipsum dolor amet alcatra</div>
693-
</div>
694-
<div data-layout="fit">
695-
<div>&gt;</div>
696-
</div>
612+
<div class="demo" data-layout="flex-cols-5">
613+
<div>5</div>
614+
<div>5</div>
615+
<div>5</div>
616+
<div>5</div>
617+
<div>5</div>
697618
</div>
698619

699-
<pre>&lt;div data-layout=&quot;flex&quot;&gt;
700-
&lt;div data-layout=&quot;fit&quot;&gt;
701-
&lt;div&gt;&amp;lt;&lt;/div&gt;
702-
&lt;/div&gt;
703-
&lt;div data-layout=&quot;fill&quot;&gt;
704-
&lt;div&gt;Ipsum dolor amet alcatra&lt;/div&gt;
705-
&lt;/div&gt;
706-
&lt;div data-layout=&quot;fit&quot;&gt;
707-
&lt;div&gt;&amp;gt;&lt;/div&gt;
708-
&lt;/div&gt;
620+
<div class="demo" data-layout="flex-cols-4">
621+
<div>4</div>
622+
<div>4</div>
623+
<div>4</div>
624+
<div>4</div>
625+
</div>
626+
627+
<div class="demo" data-layout="flex-cols-3">
628+
<div>3</div>
629+
<div>3</div>
630+
<div>3</div>
631+
</div>
632+
633+
<div class="demo" data-layout="flex-cols-2">
634+
<div>2</div>
635+
<div>2</div>
636+
<div>2</div>
637+
<div>2</div>
638+
</div>
639+
640+
<pre>&lt;div data-layout=&quot;flex-cols-5&quot;&gt;
641+
&lt;div&gt;5&lt;/div&gt;
642+
&lt;div&gt;5&lt;/div&gt;
643+
&lt;div&gt;5&lt;/div&gt;
644+
&lt;div&gt;5&lt;/div&gt;
645+
&lt;div&gt;5&lt;/div&gt;
646+
&lt;/div&gt;
647+
648+
&lt;div data-layout=&quot;flex-cols-4&quot;&gt;
649+
&lt;div&gt;4&lt;/div&gt;
650+
&lt;div&gt;4&lt;/div&gt;
651+
&lt;div&gt;4&lt;/div&gt;
652+
&lt;div&gt;4&lt;/div&gt;
653+
&lt;/div&gt;
654+
655+
&lt;div data-layout=&quot;flex-cols-3&quot;&gt;
656+
&lt;div&gt;3&lt;/div&gt;
657+
&lt;div&gt;3&lt;/div&gt;
658+
&lt;div&gt;3&lt;/div&gt;
659+
&lt;/div&gt;
660+
661+
&lt;div data-layout=&quot;flex-cols-2&quot;&gt;
662+
&lt;div&gt;2&lt;/div&gt;
663+
&lt;div&gt;2&lt;/div&gt;
664+
&lt;div&gt;2&lt;/div&gt;
665+
&lt;div&gt;2&lt;/div&gt;
666+
&lt;/div&gt;</pre>
667+
668+
<h3>Flex explicit columns</h3>
669+
670+
<p>Columns that are not uniform can define their column span value directly on the column element using <code>cols-X</code>. Multiple rows are achieved with filling columns according to the 12 column layout.</p>
671+
672+
<ul>
673+
<li><code>cols-X</code>, <code>cols-X-sm</code>, <code>cols-X-md</code>, <code>cols-X-lg</code>, <code>cols-X-xl</code></li>
674+
</ul>
675+
676+
<div class="demo" data-layout="flex-cols">
677+
<div data-layout="cols-1">1</div>
678+
<div data-layout="cols-11">11</div>
679+
680+
<div data-layout="cols-2">2</div>
681+
<div data-layout="cols-10">10</div>
682+
683+
<div data-layout="cols-3">3</div>
684+
<div data-layout="cols-9">9</div>
685+
686+
<div data-layout="cols-4">4</div>
687+
<div data-layout="cols-8">8</div>
688+
</div>
689+
690+
<pre>&lt;div data-layout=&quot;flex-cols&quot;&gt;
691+
&lt;div data-layout=&quot;cols-1&quot;&gt;1&lt;/div&gt;
692+
&lt;div data-layout=&quot;cols-11&quot;&gt;11&lt;/div&gt;
693+
694+
&lt;div data-layout=&quot;cols-2&quot;&gt;2&lt;/div&gt;
695+
&lt;div data-layout=&quot;cols-10&quot;&gt;10&lt;/div&gt;
696+
697+
&lt;div data-layout=&quot;cols-3&quot;&gt;3&lt;/div&gt;
698+
&lt;div data-layout=&quot;cols-9&quot;&gt;9&lt;/div&gt;
699+
700+
&lt;div data-layout=&quot;cols-4&quot;&gt;4&lt;/div&gt;
701+
&lt;div data-layout=&quot;cols-8&quot;&gt;8&lt;/div&gt;
702+
&lt;/div&gt;</pre>
703+
704+
<h3>Fit explicit columns</h3>
705+
706+
<p>An explicit flex column can shrink to fit the contents using <code>cols-fit</code>.</p>
707+
708+
<ul>
709+
<li><code>cols-fit</code>, <code>cols-fit-sm</code>, <code>cols-fit-md</code>, <code>cols-fit-lg</code>, <code>cols-fit-xl</code></li>
710+
</ul>
711+
712+
<div class="demo" data-layout="flex-cols-4">
713+
<div>4</div>
714+
<div>4</div>
715+
<div data-layout="cols-fit">fit</div>
716+
</div>
717+
718+
<pre>&lt;div data-layout=&quot;flex-cols-4&quot;&gt;
719+
&lt;div&gt;4&lt;/div&gt;
720+
&lt;div&gt;4&lt;/div&gt;
721+
&lt;div data-layout=&quot;cols-fit&quot;&gt;fit&lt;/div&gt;
722+
&lt;/div&gt;</pre>
723+
724+
<h3>Fill explicit columns</h3>
725+
726+
<p>An explicit flex column can fill the row using <code>cols-fill</code>.</p>
727+
728+
<ul>
729+
<li><code>cols-fill</code>, <code>cols-fill-sm</code>, <code>cols-fill-md</code>, <code>cols-fill-lg</code>, <code>cols-fill-xl</code></li>
730+
</ul>
731+
732+
<div class="demo" data-layout="flex-cols-4">
733+
<div>4</div>
734+
<div>4</div>
735+
<div data-layout="cols-fill">fill</div>
736+
</div>
737+
738+
<pre>&lt;div data-layout=&quot;flex-cols-4&quot;&gt;
739+
&lt;div&gt;4&lt;/div&gt;
740+
&lt;div&gt;4&lt;/div&gt;
741+
&lt;div data-layout=&quot;cols-fill&quot;&gt;fill&lt;/div&gt;
742+
&lt;/div&gt;</pre>
743+
744+
<h3>Flex implicit rows</h3>
745+
746+
<p>Implicit uniform rows can define their values at the parent flex element using <code>flex-rows-X</code>.</p>
747+
748+
<ul>
749+
<li><code>flex-rows-X</code>, <code>flex-rows-X-sm</code>, <code>flex-rows-X-md</code>, <code>flex-rows-X-lg</code>, <code>flex-rows-X-xl</code></li>
750+
</ul>
751+
752+
<div class="demo" data-layout="flex-rows-3" style="height: 350px;">
753+
<div>3</div>
754+
<div>3</div>
755+
<div>3</div>
756+
</div>
757+
758+
<pre>&lt;div data-layout=&quot;flex-rows-3&quot; style=&quot;height: 350px;&quot;&gt;
759+
&lt;div&gt;3&lt;/div&gt;
760+
&lt;div&gt;3&lt;/div&gt;
761+
&lt;div&gt;3&lt;/div&gt;
762+
&lt;/div&gt;</pre>
763+
764+
<h3>Flex explicit rows</h3>
765+
766+
<p>Rows that are not uniform can define their row span value directly on the element using <code>rows-X</code>.</p>
767+
768+
<ul>
769+
<li><code>rows-X</code>, <code>rows-X-sm</code>, <code>rows-X-md</code>, <code>rows-X-lg</code>, <code>rows-X-xl</code></li>
770+
</ul>
771+
772+
<div class="demo" data-layout="flex-rows" style="height: 350px;">
773+
<div data-layout="rows-2">2</div>
774+
<div data-layout="rows-4">4</div>
775+
<div data-layout="rows-6">6</div>
776+
</div>
777+
778+
<pre>&lt;div data-layout=&quot;flex-rows&quot; style=&quot;height: 350px;&quot;&gt;
779+
&lt;div data-layout=&quot;rows-2&quot;&gt;2&lt;/div&gt;
780+
&lt;div data-layout=&quot;rows-4&quot;&gt;4&lt;/div&gt;
781+
&lt;div data-layout=&quot;rows-6&quot;&gt;6&lt;/div&gt;
782+
&lt;/div&gt;</pre>
783+
784+
<h3>Fill explicit rows</h3>
785+
786+
<ul>
787+
<li><code>rows-fill</code>, <code>rows-fill-sm</code>, <code>rows-fill-md</code>, <code>rows-fill-lg</code>, <code>rows-fill-xl</code></li>
788+
</ul>
789+
790+
<div class="demo" data-layout="flex-rows-4" style="height: 350px;">
791+
<div>4</div>
792+
<div data-layout="rows-fill">fill</div>
793+
</div>
794+
795+
<pre>&lt;div data-layout=&quot;flex-rows-4&quot; style=&quot;height: 350px;&quot;&gt;
796+
&lt;div&gt;4&lt;/div&gt;
797+
&lt;div data-layout=&quot;rows-fill&quot;&gt;fill&lt;/div&gt;
709798
&lt;/div&gt;</pre>
710799

711800
</section>
@@ -819,7 +908,7 @@ <h2>Container</h2>
819908
<p>Basic <code>container</code> attribute to set max width and centered page level content. The container defaults to a maximum width of 1000px.</p>
820909

821910
<pre>&lt;div data-layout=&quot;container&quot;&gt;
822-
&lt;div&gt;Ipsum dolor amet&lt;/div&gt;
911+
&lt;p&gt;Ipsum dolor amet&lt;/p&gt;
823912
&lt;/div&gt;</pre>
824913

825914
</section>

0 commit comments

Comments
 (0)