You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: css-display-3/Overview.bs
-61
Original file line number
Diff line number
Diff line change
@@ -1031,67 +1031,6 @@ Reordering and Accessibility</h3>
1031
1031
(Since visual perception is two-dimensional and non-linear,
1032
1032
the desired visual order is not always logical.)
1033
1033
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
-
<!DOCTYPE html>
1054
-
<header>...</header>
1055
-
<main>
1056
-
<article>...</article>
1057
-
<nav>...</nav>
1058
-
<aside>...</aside>
1059
-
</main>
1060
-
<footer>...</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
-
1095
1034
In order to preserve the author's intended ordering in all presentation modes,
1096
1035
authoring tools--
1097
1036
including WYSIWYG editors as well as Web-based authoring aids--
0 commit comments