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