Skip to content

Commit 16d1492

Browse files
committed
[css-flexbox-3] Move flexbox example back to flexbox. #5865
1 parent 2ccbf7b commit 16d1492

File tree

1 file changed

+0
-61
lines changed

1 file changed

+0
-61
lines changed

css-display-3/Overview.bs

-61
Original file line numberDiff line numberDiff line change
@@ -1031,67 +1031,6 @@ Reordering and Accessibility</h3>
10311031
(Since visual perception is two-dimensional and non-linear,
10321032
the desired visual order is not always logical.)
10331033

1034-
<div class='example'>
1035-
Many web pages have a similar shape in the markup,
1036-
with a header on top,
1037-
a footer on bottom,
1038-
and then a content area and one or two additional columns in the middle.
1039-
Generally,
1040-
it's desirable that the content come first in the page's source code,
1041-
before the additional columns.
1042-
However, this makes many common designs,
1043-
such as simply having the additional columns on the left and the content area on the right,
1044-
difficult to achieve.
1045-
This has been addressed in many ways over the years,
1046-
often going by the name "Holy Grail Layout" when there are two additional columns.
1047-
'order' makes this trivial.
1048-
For example, take the following sketch of a page's code and desired layout:
1049-
1050-
<div class='code-and-figure'>
1051-
<div>
1052-
<pre class="lang-markup">
1053-
&lt;!DOCTYPE html>
1054-
&lt;header>...&lt;/header>
1055-
&lt;main>
1056-
&lt;article>...&lt;/article>
1057-
&lt;nav>...&lt;/nav>
1058-
&lt;aside>...&lt;/aside>
1059-
&lt;/main>
1060-
&lt;footer>...&lt;/footer>
1061-
</pre>
1062-
</div>
1063-
<div><img src="images/flex-order-page.svg" width=400 height=360 alt="In this page the header is at the top and the footer at the bottom, but the article is in the center, flanked by the nav on the right and the aside on the left."></div>
1064-
</div>
1065-
1066-
This layout can be easily achieved with flex layout:
1067-
1068-
<pre class="lang-css">
1069-
main { display: flex; }
1070-
main > article { order: 2; min-width: 12em; flex:1; }
1071-
main > nav { order: 1; width: 200px; }
1072-
main > aside { order: 3; width: 200px; }
1073-
</pre>
1074-
1075-
As an added bonus,
1076-
the columns will all be <a value for=align-self lt=stretch>equal-height</a> by default,
1077-
and the main content will be as wide as necessary to fill the screen.
1078-
Additionally,
1079-
this can then be combined with media queries to switch to an all-vertical layout on narrow screens:
1080-
1081-
<pre class="lang-css">
1082-
@media all and (max-width: 600px) {
1083-
/* Too narrow to support three columns */
1084-
main { flex-flow: column; }
1085-
main > article, main > nav, main > aside {
1086-
/* Return them to document order */
1087-
order: 0; width: auto;
1088-
}
1089-
}
1090-
</pre>
1091-
1092-
<small>(Further use of multi-line flex containers to achieve even more intelligent wrapping left as an exercise for the reader.)</small>
1093-
</div>
1094-
10951034
In order to preserve the author's intended ordering in all presentation modes,
10961035
authoring tools--
10971036
including WYSIWYG editors as well as Web-based authoring aids--

0 commit comments

Comments
 (0)