Skip to content

Commit a657652

Browse files
committed
Ex5 - Flex panel images
1 parent 285447e commit a657652

File tree

7 files changed

+152
-0
lines changed

7 files changed

+152
-0
lines changed

05 - Flex Panel Gallery/01.jpg

472 KB
Loading

05 - Flex Panel Gallery/02.jpg

376 KB
Loading

05 - Flex Panel Gallery/03.jpg

747 KB
Loading

05 - Flex Panel Gallery/04.jpg

505 KB
Loading

05 - Flex Panel Gallery/05.jpg

511 KB
Loading

05 - Flex Panel Gallery/index.html

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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;
46+
display: flex;
47+
flex-direction: column;
48+
}
49+
50+
51+
.panel1 { background-image:url(01.jpg); }
52+
.panel2 { background-image:url(02.jpg); }
53+
.panel3 { background-image:url(03.jpg); }
54+
.panel4 { background-image:url(04.jpg); }
55+
.panel5 { background-image:url(05.jpg); }
56+
57+
.panel > * {
58+
margin:0;
59+
width: 100%;
60+
transition:transform 0.5s;
61+
flex: 1;
62+
}
63+
64+
.panel :first-child {
65+
transform: translateY(-100%);
66+
}
67+
68+
.panel :last-child {
69+
transform: translateY(100%);
70+
}
71+
72+
73+
.panel.open-active :first-child,
74+
.panel.open-active :last-child {
75+
transform: translateY(0);
76+
}
77+
78+
.panel p {
79+
text-transform: uppercase;
80+
font-family: 'Amatic SC', cursive;
81+
text-shadow:0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45);
82+
font-size: 2em;
83+
display : flex;
84+
align-items: center;
85+
justify-content: center;
86+
}
87+
.panel p:nth-child(2) {
88+
font-size: 4em;
89+
}
90+
91+
.panel.open {
92+
flex: 5;
93+
font-size:40px;
94+
}
95+
96+
.cta {
97+
color:white;
98+
text-decoration: none;
99+
}
100+
101+
</style>
102+
103+
104+
<div class="panels">
105+
<div class="panel panel1">
106+
<p>Hey</p>
107+
<p>Let's</p>
108+
<p>Dance</p>
109+
</div>
110+
<div class="panel panel2">
111+
<p>Give</p>
112+
<p>Take</p>
113+
<p>Receive</p>
114+
</div>
115+
<div class="panel panel3">
116+
<p>Experience</p>
117+
<p>It</p>
118+
<p>Today</p>
119+
</div>
120+
<div class="panel panel4">
121+
<p>Give</p>
122+
<p>All</p>
123+
<p>You can</p>
124+
</div>
125+
<div class="panel panel5">
126+
<p>Life</p>
127+
<p>In</p>
128+
<p>Motion</p>
129+
</div>
130+
</div>
131+
132+
<script src="script.js" charset="utf-8"></script>
133+
134+
</body>
135+
</html>

05 - Flex Panel Gallery/script.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
3+
const panels = document.querySelectorAll('.panel');
4+
5+
function togglePanel() {
6+
this.classList.toggle('open');
7+
}
8+
9+
function toggleActive(e) {
10+
console.log(this.classList);
11+
if (e.propertyName.includes('flex')) {
12+
this.classList.toggle('open-active');
13+
}
14+
}
15+
16+
panels.forEach(panel => panel.addEventListener('click', togglePanel));
17+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive));

0 commit comments

Comments
 (0)