Skip to content

Commit 01b1106

Browse files
committed
✓ Day 5
1 parent d6ed5d5 commit 01b1106

File tree

1 file changed

+155
-0
lines changed

1 file changed

+155
-0
lines changed

05 - Flex Panel Gallery/index.html

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Flex Panels 💪</title>
6+
<link href='https://fonts.googleapis.com/css?family=Amatic+SC' rel='stylesheet' type='text/css'>
7+
</head>
8+
<body>
9+
<style>
10+
html {
11+
box-sizing: border-box;
12+
background:#ffc600;
13+
font-family:'helvetica neue';
14+
font-size: 20px;
15+
font-weight: 200;
16+
}
17+
body {
18+
margin: 0;
19+
}
20+
*, *:before, *:after {
21+
box-sizing: inherit;
22+
}
23+
24+
.panels {
25+
min-height:100vh;
26+
overflow: hidden;
27+
display: flex;
28+
}
29+
30+
.panel {
31+
background:#6B0F9C;
32+
box-shadow:inset 0 0 0 5px rgba(255,255,255,0.1);
33+
color:white;
34+
text-align: center;
35+
align-items:center;
36+
/* Safari transitionend event.propertyName === flex */
37+
/* Chrome + FF transitionend event.propertyName === flex-grow */
38+
transition:
39+
font-size 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
40+
flex 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
41+
background 0.2s;
42+
font-size: 20px;
43+
background-size:cover;
44+
background-position:center;
45+
flex: 1; /* Its property as a flex child of .panels */
46+
/* Also make it a flex parent, of its content */
47+
display: flex;
48+
flex-direction: column;
49+
50+
justify-content: center;
51+
}
52+
53+
54+
.panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); }
55+
.panel2 { background-image:url(https://source.unsplash.com/1CD3fd8kHnE/1500x1500); }
56+
.panel3 { background-image:url(https://images.unsplash.com/photo-1465188162913-8fb5709d6d57?ixlib=rb-0.3.5&q=80&fm=jpg&crop=faces&cs=tinysrgb&w=1500&h=1500&fit=crop&s=967e8a713a4e395260793fc8c802901d); }
57+
.panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); }
58+
.panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); }
59+
60+
.panel > * {
61+
margin:0;
62+
width: 100%;
63+
transition:transform 0.5s;
64+
flex: 1 0 auto;
65+
display: flex;
66+
justify-content: center;
67+
align-items: center;
68+
}
69+
70+
.panel p {
71+
text-transform: uppercase;
72+
font-family: 'Amatic SC', cursive;
73+
text-shadow:0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45);
74+
font-size: 2em;
75+
}
76+
.panel p:nth-child(2) {
77+
font-size: 4em;
78+
}
79+
80+
.panel > *:first-child {
81+
transform: translateY(-100%);
82+
}
83+
.panel.open-active > *:first-child {
84+
transform: translateY(0);
85+
}
86+
87+
.panel > *:last-child {
88+
transform: translateY(100%);
89+
}
90+
.panel.open-active > *:last-child {
91+
transform: translateY(0);
92+
}
93+
94+
.panel.open {
95+
flex: 5;
96+
font-size:40px;
97+
}
98+
99+
.cta {
100+
color:white;
101+
text-decoration: none;
102+
}
103+
104+
</style>
105+
106+
107+
<div class="panels">
108+
<div class="panel panel1">
109+
<p>Hey</p>
110+
<p>Let's</p>
111+
<p>Dance</p>
112+
</div>
113+
<div class="panel panel2">
114+
<p>Give</p>
115+
<p>Take</p>
116+
<p>Receive</p>
117+
</div>
118+
<div class="panel panel3">
119+
<p>Experience</p>
120+
<p>It</p>
121+
<p>Today</p>
122+
</div>
123+
<div class="panel panel4">
124+
<p>Give</p>
125+
<p>All</p>
126+
<p>You can</p>
127+
</div>
128+
<div class="panel panel5">
129+
<p>Life</p>
130+
<p>In</p>
131+
<p>Motion</p>
132+
</div>
133+
</div>
134+
135+
<script>
136+
const panels = document.querySelectorAll('.panel')
137+
138+
function toggleOpen () {
139+
this.classList.toggle('open')
140+
}
141+
142+
function toggleActive (e) {
143+
if (e.propertyName.includes('flex')) {
144+
this.classList.toggle('open-active')
145+
}
146+
}
147+
148+
panels.forEach(panel => panel.addEventListener('click', toggleOpen))
149+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive))
150+
</script>
151+
152+
153+
154+
</body>
155+
</html>

0 commit comments

Comments
 (0)