Visitar URL original
close enough solution for exercise 5 without watching the video · wesbos/JavaScript30@5cd9e8d · GitHub
Skip to content

Commit 5cd9e8d

Browse files
author
Rasool, Zeeshan (UK - London)
committed
close enough solution for exercise 5 without watching the video
1 parent cac277a commit 5cd9e8d

1 file changed

Lines changed: 143 additions & 0 deletions

File tree

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
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+
display: flex;
26+
min-height:100vh;
27+
overflow: hidden;
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+
display: flex;
46+
flex-direction: column;
47+
justify-content: center;
48+
flex-grow: 1;
49+
}
50+
51+
52+
.panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); }
53+
.panel2 { background-image:url(https://source.unsplash.com/1CD3fd8kHnE/1500x1500); }
54+
.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); }
55+
.panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); }
56+
.panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); }
57+
58+
.panel > * {
59+
margin:0;
60+
width: 100%;
61+
transition: transform 0.5s 0.4s;
62+
}
63+
64+
.panel p {
65+
text-transform: uppercase;
66+
font-family: 'Amatic SC', cursive;
67+
text-shadow:0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45);
68+
font-size: 2em;
69+
pointer-events: none;
70+
}
71+
.panel p:nth-child(2) {
72+
font-size: 4em;
73+
}
74+
75+
.panel p:nth-child(1) {
76+
transform: translateY(-100vh);
77+
}
78+
79+
.panel p:nth-child(3) {
80+
transform: translateY(100vh);
81+
}
82+
83+
.panel.open {
84+
font-size: 40px;
85+
flex-grow: 5;
86+
}
87+
88+
.panel.open p:nth-child(1),
89+
.panel.open p:nth-child(3) {
90+
transform: translateY(0);
91+
}
92+
93+
.cta {
94+
color:white;
95+
text-decoration: none;
96+
}
97+
98+
</style>
99+
100+
101+
<div class="panels">
102+
<div class="panel panel1">
103+
<p>Hey</p>
104+
<p>Let's</p>
105+
<p>Dance</p>
106+
</div>
107+
<div class="panel panel2">
108+
<p>Give</p>
109+
<p>Take</p>
110+
<p>Receive</p>
111+
</div>
112+
<div class="panel panel3">
113+
<p>Experience</p>
114+
<p>It</p>
115+
<p>Today</p>
116+
</div>
117+
<div class="panel panel4">
118+
<p>Give</p>
119+
<p>All</p>
120+
<p>You can</p>
121+
</div>
122+
<div class="panel panel5">
123+
<p>Life</p>
124+
<p>In</p>
125+
<p>Motion</p>
126+
</div>
127+
</div>
128+
129+
<script>
130+
(function animatePanels () {
131+
const panels = document.querySelectorAll('.panel');
132+
panels.forEach((panel) => {
133+
panel.addEventListener('click', (e) => {
134+
e.target.classList.contains('open') ? e.target.classList.remove('open') : e.target.classList.add('open');
135+
});
136+
});
137+
})();
138+
</script>
139+
140+
141+
142+
</body>
143+
</html>

0 commit comments

Comments
 (0)