-
Notifications
You must be signed in to change notification settings - Fork 2
/
responsive-design-flexbox-holy-grail.html
92 lines (91 loc) · 1.81 KB
/
responsive-design-flexbox-holy-grail.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
<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Responsive Patterns - Flexbox Holy Grail</title>
<style type="text/css">
body {
background: grey;
}
.container {
width: 100%;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-flow: row wrap;
flex-flow: row wrap;
}
.container > * {
padding: 1em;
-webkit-flex: 1 100%;
flex: 1 100%;
}
.header {
text-align: center;
background: tomato;
}
.footer {
background: lightgreen;
}
.main {
background: deepskyblue;
}
.nav {
background: gold;
}
.aside {
background: hotpink;
}
/* Small screens */
/* Source order for mobile-first approach:
header, main, nav, aside, footer */
/* Medium screens */
@media screen and (min-width: 550px) {
.nav, .aside {
-webkit-flex: 1 auto;
flex: 1 auto;
}
}
/* Large screens */
@media screen and (min-width: 850px) {
.nav {
-webkit-order: 1;
order: 1;
}
.main {
-webkit-flex: 3 0px;
flex: 3 0px;
-webkit-order: 2;
order: 2;
}
.aside {
-webkit-order: 3;
order: 3;
}
.footer {
-webkit-order: 4;
order: 4;
}
}
/* Margins for wide screens */
@media screen and (min-width: 950px) {
.container {
width: 950px;
margin-left: auto;
margin-right: auto;
}
}
</style>
</head>
<body>
<div class="container">
<header class="header">Responsive Web Design</header>
<article class="main">Here is the example of mobile-first 3-columns layout with full-width header and footer, implemented using the CSS flexbox.</article>
<nav class="nav">Nav</nav>
<aside class="aside">Aside</aside>
<footer class="footer">Footer</footer>
</div>
</body>
</html>