Skip to content

Commit ad7c8e2

Browse files
committed
[css-regions] add menu example
1 parent fd1f809 commit ad7c8e2

7 files changed

Lines changed: 240 additions & 11 deletions

File tree

css-regions/Overview.html

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
</p>
5757
<h1 class="p-name no-ref" id=title>CSS Regions Module Level 1</h1>
5858
<h2 class="no-num no-toc no-ref heading settled heading" id=subtitle><span class=content>Editor’s Draft,
59-
<span class=dt-updated><span class=value-title title=20140311>11 March 2014</span></span></span></h2>
59+
<span class=dt-updated><span class=value-title title=20140325>25 March 2014</span></span></span></h2>
6060
<div data-fill-with=spec-metadata><dl><dt>This version:<dd><a class=u-url href=http://dev.w3.org/csswg/css-regions/>http://dev.w3.org/csswg/css-regions/</a><dt>Latest version:<dd><a href=http://www.w3.org/TR/css-regions/>http://www.w3.org/TR/css-regions/</a><dt>Editor’s Draft:<dd><a href=http://dev.w3.org/csswg/css-regions/>http://dev.w3.org/csswg/css-regions/</a>
6161
<dt>Feedback:</dt>
6262
<dd><a href="mailto:www-style@w3.org?subject=%5Bcss-regions%5D%20feedback">www-style@w3.org</a>
@@ -225,10 +225,9 @@ <h2 class="heading settled heading" data-level=1 id=introduction><span class=sec
225225
and flowing content through areas in a paginated view.
226226

227227
<div class=example>
228-
For instance,
229-
linked display boxes could be created
228+
Linked display boxes can be created
230229
to display article content above and below
231-
some additional content on a page.
230+
other content on a page.
232231
Given markup like this:
233232

234233
<pre><code class=html>
@@ -295,8 +294,43 @@ <h2 class="heading settled heading" data-level=1 id=introduction><span class=sec
295294
</div>
296295

297296
<div class=example>
298-
An example of custom overflow handling creates an additional box inside a menu for <nav> items that would overflow a narrow navigation bar.
299-
</nav></div>
297+
Custom overflow handling can be accomplished by linking a separate overflow box. In this example, the overflow box is nestled inside a menu in the markup, and only displays if the menu is toggled.
298+
299+
<pre><code class=html>
300+
&lt;nav&gt; ...some links... &lt;/nav&gt;
301+
302+
&lt;div class="menu"&gt;
303+
&lt;nav&gt;&lt;/nav&gt;
304+
...some more links...
305+
&lt;/div&gt;
306+
</code></pre>
307+
<p> If the links in the main nav element are placed in a named flow, that flow can be directed through both the main nav element and the overflow nav box in the menu:
308+
309+
<pre><code class=css>
310+
nav a {
311+
flow-into: nav-link-flow;
312+
}
313+
nav {
314+
flow-from: nav-link-flow;
315+
}
316+
</code></pre>
317+
<p> Then the main nav element and the menu can be arranged with constraints such that when the screen is too narrow for the main nav element to display all of the navigation links, the overflow moves to the menu.
318+
319+
</p><figure>
320+
<img alt="Wide nav bar showing all of the links" src=images/menu-wide.png>
321+
<figcaption>
322+
Wide rendering with menu shown
323+
</figcaption>
324+
</figure>
325+
326+
<figure>
327+
<img alt="Narrow nav bar with some of the links in the menu" src=images/menu-narrow.png>
328+
<figcaption>
329+
Narrow rendering with menu shown
330+
</figcaption>
331+
</figure>
332+
333+
</div>
300334

301335
<div class=example>
302336
An example of aggregating content can fill a named flow with content from multiple sources.
@@ -2355,7 +2389,7 @@ <h2 class="no-num no-ref heading settled heading" id=references><span class=cont
23552389

23562390
<h3 class="no-num no-ref heading settled heading" id=normative><span class=content>
23572391
Normative References</span><a class=self-link href=#normative></a></h3>
2358-
<div data-fill-with=normative-references><dl><dt id=css21 title=CSS21><a class=self-link href=#css21></a>[CSS21]<dd>Bert Bos; et al. <a href=http://www.w3.org/TR/2011/REC-CSS2-20110607>Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification</a>. 7 June 2011. W3C Recommendation. URL: <a href=http://www.w3.org/TR/2011/REC-CSS2-20110607>http://www.w3.org/TR/2011/REC-CSS2-20110607</a><dt id=css3-break title=CSS3-BREAK><a class=self-link href=#css3-break></a>[CSS3-BREAK]<dd>Rossen Atanassov; Elika J. Etemad. <a href=http://www.w3.org/TR/2012/WD-css3-break-20120823/>CSS Fragmentation Module Level 3</a>. 23 August 2012. W3C Working Draft. (Work in progress.) URL: <a href=http://www.w3.org/TR/2012/WD-css3-break-20120823/>http://www.w3.org/TR/2012/WD-css3-break-20120823/</a><dt id=css3-writing-modes title=CSS3-WRITING-MODES><a class=self-link href=#css3-writing-modes></a>[CSS3-WRITING-MODES]<dd>Elika J. Etemad; Koji Ishii. <a href=http://www.w3.org/TR/2012/WD-css3-writing-modes-20121115/>CSS Writing Modes Module Level 3</a>. 15 November 2012. W3C Working Draft. (Work in progress.) URL: <a href=http://www.w3.org/TR/2012/WD-css3-writing-modes-20121115/>http://www.w3.org/TR/2012/WD-css3-writing-modes-20121115/</a><dt id=css3col title=CSS3COL><a class=self-link href=#css3col></a>[CSS3COL]<dd>Håkon Wium Lie. <a href=http://www.w3.org/TR/2011/CR-css3-multicol-20110412>CSS Multi-column Layout Module</a>. 12 April 2011. W3C Candidate Recommendation. (Work in progress.) URL: <a href=http://www.w3.org/TR/2011/CR-css3-multicol-20110412>http://www.w3.org/TR/2011/CR-css3-multicol-20110412</a><dt id=cssom title=CSSOM><a class=self-link href=#cssom></a>[CSSOM]<dd>Anne van Kesteren. <a href=http://www.w3.org/TR/2011/WD-cssom-20110712/>CSSOM</a>. 12 July 2011. W3C Working Draft. (Work in progress.) URL: <a href=http://www.w3.org/TR/2011/WD-cssom-20110712/>http://www.w3.org/TR/2011/WD-cssom-20110712/</a><dt id=dom title=DOM><a class=self-link href=#dom></a>[DOM]<dd>Anne van Kesteren; et al. <a href=http://www.w3.org/TR/2012/WD-dom-20121206/>DOM4</a>. 6 December 2012. W3C Working Draft. (Work in progress.) URL: <a href=http://www.w3.org/TR/2012/WD-dom-20121206/>http://www.w3.org/TR/2012/WD-dom-20121206/</a><dt id=dom-level-3-events title=DOM-LEVEL-3-EVENTS><a class=self-link href=#dom-level-3-events></a>[DOM-LEVEL-3-EVENTS]<dd>Travis Leithead; et al. <a href=http://www.w3.org/TR/2012/WD-DOM-Level-3-Events-20120906/>Document Object Model (DOM) Level 3 Events Specification</a>. 6 September 2012. W3C Working Draft. (Work in progress.) URL: <a href=http://www.w3.org/TR/2012/WD-DOM-Level-3-Events-20120906/>http://www.w3.org/TR/2012/WD-DOM-Level-3-Events-20120906/</a><dt id=rfc2119 title=RFC2119><a class=self-link href=#rfc2119></a>[RFC2119]<dd>S. Bradner. <a href=http://www.ietf.org/rfc/rfc2119.txt>Key words for use in RFCs to Indicate Requirement Levels</a>. URL: <a href=http://www.ietf.org/rfc/rfc2119.txt>http://www.ietf.org/rfc/rfc2119.txt</a><dt id=select title=SELECT><a class=self-link href=#select></a>[SELECT]<dd>Tantek Çelik; et al. <a href=http://www.w3.org/TR/2011/REC-css3-selectors-20110929/>Selectors Level 3</a>. 29 September 2011. W3C Recommendation. URL: <a href=http://www.w3.org/TR/2011/REC-css3-selectors-20110929/>http://www.w3.org/TR/2011/REC-css3-selectors-20110929/</a></dl></div>
2392+
<div data-fill-with=normative-references><dl><dt id=css21 title=CSS21><a class=self-link href=#css21></a>[CSS21]<dd>Bert Bos; et al. <a href=http://www.w3.org/TR/2011/REC-CSS2-20110607>Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification</a>. 7 June 2011. W3C Recommendation. URL: <a href=http://www.w3.org/TR/2011/REC-CSS2-20110607>http://www.w3.org/TR/2011/REC-CSS2-20110607</a><dt id=css3-break title=CSS3-BREAK><a class=self-link href=#css3-break></a>[CSS3-BREAK]<dd>Rossen Atanassov; Elika J. Etemad. <a href=http://www.w3.org/TR/2012/WD-css3-break-20120823/>CSS Fragmentation Module Level 3</a>. 23 August 2012. W3C Working Draft. (Work in progress.) URL: <a href=http://www.w3.org/TR/2012/WD-css3-break-20120823/>http://www.w3.org/TR/2012/WD-css3-break-20120823/</a><dt id=css3-writing-modes title=CSS3-WRITING-MODES><a class=self-link href=#css3-writing-modes></a>[CSS3-WRITING-MODES]<dd>Elika J. Etemad; Koji Ishii. <a href=http://www.w3.org/TR/2012/WD-css3-writing-modes-20121115/>CSS Writing Modes Module Level 3</a>. 15 November 2012. W3C Working Draft. (Work in progress.) URL: <a href=http://www.w3.org/TR/2012/WD-css3-writing-modes-20121115/>http://www.w3.org/TR/2012/WD-css3-writing-modes-20121115/</a><dt id=css3col title=CSS3COL><a class=self-link href=#css3col></a>[CSS3COL]<dd>Håkon Wium Lie. <a href=http://www.w3.org/TR/2011/CR-css3-multicol-20110412>CSS Multi-column Layout Module</a>. 12 April 2011. W3C Candidate Recommendation. (Work in progress.) URL: <a href=http://www.w3.org/TR/2011/CR-css3-multicol-20110412>http://www.w3.org/TR/2011/CR-css3-multicol-20110412</a><dt id=cssom title=CSSOM><a class=self-link href=#cssom></a>[CSSOM]<dd>Anne van Kesteren. <a href=http://www.w3.org/TR/2011/WD-cssom-20110712/>CSSOM</a>. 12 July 2011. W3C Working Draft. (Work in progress.) URL: <a href=http://www.w3.org/TR/2011/WD-cssom-20110712/>http://www.w3.org/TR/2011/WD-cssom-20110712/</a><dt id=dom title=DOM><a class=self-link href=#dom></a>[DOM]<dd>Anne van Kesteren; Aryeh Gregor; Ms2ger. <a href=http://dom.spec.whatwg.org/>DOM Living Standard</a>. WHATWG Living Standard. (Work in progress.) URL: <a href=http://dom.spec.whatwg.org/>http://dom.spec.whatwg.org/</a><dt id=dom-level-3-events title=DOM-LEVEL-3-EVENTS><a class=self-link href=#dom-level-3-events></a>[DOM-LEVEL-3-EVENTS]<dd>Travis Leithead; et al. <a href=http://www.w3.org/TR/2012/WD-DOM-Level-3-Events-20120906/>Document Object Model (DOM) Level 3 Events Specification</a>. 6 September 2012. W3C Working Draft. (Work in progress.) URL: <a href=http://www.w3.org/TR/2012/WD-DOM-Level-3-Events-20120906/>http://www.w3.org/TR/2012/WD-DOM-Level-3-Events-20120906/</a><dt id=rfc2119 title=RFC2119><a class=self-link href=#rfc2119></a>[RFC2119]<dd>S. Bradner. <a href=http://www.ietf.org/rfc/rfc2119.txt>Key words for use in RFCs to Indicate Requirement Levels</a>. URL: <a href=http://www.ietf.org/rfc/rfc2119.txt>http://www.ietf.org/rfc/rfc2119.txt</a><dt id=select title=SELECT><a class=self-link href=#select></a>[SELECT]<dd>Tantek Çelik; et al. <a href=http://www.w3.org/TR/2011/REC-css3-selectors-20110929/>Selectors Level 3</a>. 29 September 2011. W3C Recommendation. URL: <a href=http://www.w3.org/TR/2011/REC-css3-selectors-20110929/>http://www.w3.org/TR/2011/REC-css3-selectors-20110929/</a></dl></div>
23592393

23602394
<h3 class="no-num no-ref heading settled heading" id=informative><span class=content>
23612395
Informative References</span><a class=self-link href=#informative></a></h3>

css-regions/Overview.src.html

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@ <h2 id="introduction">
5858
and flowing content through areas in a paginated view.
5959

6060
<div class="example">
61-
For instance,
62-
linked display boxes could be created
61+
Linked display boxes can be created
6362
to display article content above and below
64-
some additional content on a page.
63+
other content on a page.
6564
Given markup like this:
6665

6766
<pre><code class="html">
@@ -133,7 +132,46 @@ <h2 id="introduction">
133132
</div>
134133

135134
<div class="example">
136-
An example of custom overflow handling creates an additional box inside a menu for <nav> items that would overflow a narrow navigation bar.
135+
Custom overflow handling can be accomplished by linking a separate overflow box. In this example, the overflow box is nestled inside a menu in the markup, and only displays if the menu is toggled.
136+
137+
<pre><code class="html">
138+
&lt;nav&gt; ...some links... &lt;/nav&gt;
139+
140+
&lt;div class="menu"&gt;
141+
&lt;nav&gt;&lt;/nav&gt;
142+
...some more links...
143+
&lt;/div&gt;
144+
</code></pre>
145+
146+
If the links in the main nav element are placed in a named flow, that flow can be directed through both the main nav element and the overflow nav box in the menu:
147+
148+
<pre><code class="css">
149+
nav a {
150+
flow-into: nav-link-flow;
151+
}
152+
nav {
153+
flow-from: nav-link-flow;
154+
}
155+
</code></pre>
156+
157+
Then the main nav element and the menu can be arranged with constraints such that when the screen is too narrow for the main nav element to display all of the navigation links, the overflow moves to the menu.
158+
159+
<figure>
160+
<img alt="Wide nav bar showing all of the links"
161+
src="images/menu-wide.png"/>
162+
<figcaption>
163+
Wide rendering with menu shown
164+
</figcaption>
165+
</figure>
166+
167+
<figure>
168+
<img alt="Narrow nav bar with some of the links in the menu"
169+
src="images/menu-narrow.png"/>
170+
<figcaption>
171+
Narrow rendering with menu shown
172+
</figcaption>
173+
</figure>
174+
137175
</div>
138176

139177
<div class="example">
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Responsive Menu | CSS Regions</title>
6+
7+
<style>
8+
9+
body {
10+
-width: 550px;
11+
-width: 350px;
12+
}
13+
14+
body, html{
15+
margin: 0;
16+
padding: 0;
17+
}
18+
19+
#nav-global a:hover{
20+
text-decoration: underline;
21+
}
22+
23+
header{
24+
box-sizing: border-box;
25+
display: -webkit-flex;
26+
height: 3rem;
27+
border-bottom: 1px solid #E3E3DB;
28+
background: #F4F4EE;
29+
}
30+
31+
32+
#nav-global{
33+
height: 3rem;
34+
-webkit-flex: 1 1 auto;
35+
padding-left: 1rem;
36+
}
37+
38+
/* #nav-global a{ */
39+
a {
40+
text-decoration: none;
41+
margin-right: 1.3rem;
42+
padding: 0.5rem 0 0;
43+
float: left;
44+
color: #333;
45+
font: 1.3rem/1.9rem normal georgia,serif;
46+
}
47+
48+
#menu {
49+
display: -webkit-flex;
50+
-webkit-justify-content: flex-end;
51+
-webkit-align-items: center;
52+
position: relative;
53+
-webkit-flex: 1 0 auto;
54+
}
55+
56+
#menu aside{
57+
visibility: hidden; /* toggled by JavaScript */
58+
background: #F4F4EE;
59+
max-width: 5rem;
60+
padding: 0.5rem 1rem 1rem;
61+
position: absolute;
62+
top: calc(3rem - 1px);
63+
border: none;
64+
right: 0;
65+
}
66+
67+
#menu aside.visible{
68+
visibility: visible;
69+
}
70+
71+
#menu .end{
72+
display: block;
73+
margin: 1rem 0 0;
74+
padding: 1rem 0 0;
75+
border-top: 1px solid #E24D4D;
76+
color: rgba(252,252,252,0.7);
77+
font-family: helvetica, arial, serif;
78+
}
79+
80+
#menu .toggle{
81+
text-align: center;
82+
border: 2px solid rgb(75, 75, 75);
83+
border-radius: 8px;
84+
display: block;
85+
text-decoration: none;
86+
font: .9rem/1.1rem sans-serif;
87+
width: 3.4rem;
88+
height: 1rem;
89+
padding: 0;
90+
}
91+
92+
/* collect all nav links */
93+
#nav-global a{
94+
-webkit-flow-into: menu;
95+
}
96+
97+
/* reflow nav links into original container and overflow into another element */
98+
#nav-global,
99+
#nav-compact{
100+
-webkit-flow-from: menu;
101+
}
102+
103+
</style>
104+
</head>
105+
<body>
106+
107+
<header>
108+
<nav id="nav-global">
109+
<a href="#">This</a>
110+
<a href="#">That</a>
111+
<a href="#">Other</a>
112+
<a href="#">Extra</a>
113+
<a href="#">More</a>
114+
<a href="#">Misc.</a>
115+
</nav>
116+
117+
<div id="menu">
118+
<a href="#" class="toggle">MENU</a>
119+
120+
<aside class="visible">
121+
<nav id="nav-compact">
122+
<!-- #global nav items will flow here -->
123+
</nav>
124+
<div class="end">
125+
<a href="#">Contact</a>
126+
<a href="#">About</a>
127+
<a href="#">Help</a>
128+
</div>
129+
</aside>
130+
131+
</div>
132+
</header>
133+
134+
<script>
135+
136+
var toggle = document.querySelector('.toggle'),
137+
aside = document.querySelector('aside');
138+
139+
toggle.addEventListener('click', function(){
140+
aside.classList.toggle('visible')
141+
})
142+
143+
var property = "flow-into";
144+
145+
// check if any variant exists, prefixed or not
146+
var isCapable = ['-webkit-','-ms-','-moz-',''].some(function(prefix){
147+
return prefix + property in document.body.style
148+
})
149+
150+
property = isCapable ? property : 'no-' + property;
151+
152+
document.body.classList.add(property)
153+
154+
</script>
155+
156+
</body>
157+
</html>
9.81 KB
Loading
11.9 KB
Loading

css-regions/images/menu-narrow.png

18.2 KB
Loading

css-regions/images/menu-wide.png

17.8 KB
Loading

0 commit comments

Comments
 (0)