Skip to content

Commit 84aa759

Browse files
committed
finished day 5
1 parent 1118ea9 commit 84aa759

1 file changed

Lines changed: 78 additions & 16 deletions

File tree

05 - Flex Panel Gallery/index-START.html

Lines changed: 78 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<!DOCTYPE html>
22
<html lang="en">
3+
34
<head>
45
<meta charset="UTF-8">
56
<title>Flex Panels 💪</title>
67
<link href='https://fonts.googleapis.com/css?family=Amatic+SC' rel='stylesheet' type='text/css'>
78
</head>
9+
810
<body>
911
<style>
1012
html {
@@ -14,48 +16,91 @@
1416
font-size: 20px;
1517
font-weight: 200;
1618
}
17-
19+
1820
body {
1921
margin: 0;
2022
}
21-
22-
*, *:before, *:after {
23+
24+
*,
25+
*:before,
26+
*:after {
2327
box-sizing: inherit;
2428
}
2529

2630
.panels {
2731
min-height: 100vh;
2832
overflow: hidden;
33+
display: flex;
2934
}
3035

3136
.panel {
3237
background: #6B0F9C;
33-
box-shadow: inset 0 0 0 5px rgba(255,255,255,0.1);
38+
box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.1);
3439
color: white;
3540
text-align: center;
3641
align-items: center;
3742
/* Safari transitionend event.propertyName === flex */
3843
/* Chrome + FF transitionend event.propertyName === flex-grow */
3944
transition:
40-
font-size 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
41-
flex 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
42-
background 0.2s;
45+
font-size 0.4s cubic-bezier(0.61, -0.19, 0.7, -0.11),
46+
flex 0.4s cubic-bezier(0.61, -0.19, 0.7, -0.11),
47+
background 0.3s;
4348
font-size: 20px;
4449
background-size: cover;
4550
background-position: center;
51+
flex: 1;
52+
justify-content: center;
53+
align-items: center;
54+
display: flex;
55+
flex-direction: column;
56+
}
57+
58+
.panel1 {
59+
background-image: url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500);
60+
}
61+
62+
.panel2 {
63+
background-image: url(https://source.unsplash.com/rFKUFzjPYiQ/1500x1500);
64+
}
65+
66+
.panel3 {
67+
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);
68+
}
69+
70+
.panel4 {
71+
background-image: url(https://source.unsplash.com/ITjiVXcwVng/1500x1500);
4672
}
4773

48-
.panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); }
49-
.panel2 { background-image:url(https://source.unsplash.com/rFKUFzjPYiQ/1500x1500); }
50-
.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); }
51-
.panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); }
52-
.panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); }
74+
.panel5 {
75+
background-image: url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500);
76+
}
5377

5478
/* Flex Children */
55-
.panel > * {
79+
.panel>* {
5680
margin: 0;
5781
width: 100%;
5882
transition: transform 0.5s;
83+
border: 1px solid magenta;
84+
flex: 1 0 auto;
85+
display: flex;
86+
justify-content: center;
87+
align-items: center;
88+
}
89+
90+
.panel>*:first-child {
91+
transform: translateY(-100%)
92+
}
93+
94+
.panel.open-active>*:first-child {
95+
transform: translateY(0)
96+
}
97+
98+
.panel>*:last-child {
99+
transform: translateY(100%)
100+
}
101+
102+
.panel.open-active>*:last-child {
103+
transform: translateY(0)
59104
}
60105

61106
.panel p {
@@ -64,15 +109,15 @@
64109
text-shadow: 0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45);
65110
font-size: 2em;
66111
}
67-
112+
68113
.panel p:nth-child(2) {
69114
font-size: 4em;
70115
}
71116

72117
.panel.open {
118+
flex: 5;
73119
font-size: 40px;
74120
}
75-
76121
</style>
77122

78123

@@ -105,10 +150,27 @@
105150
</div>
106151

107152
<script>
153+
const panels = document.querySelectorAll('.panel')
154+
155+
function toggleOpen() {
156+
this.classList.toggle('open')
157+
}
158+
159+
function toggleActive(e) {
160+
//console.log(e.propertyName);
161+
if (e.propertyName.includes('flex')) {
162+
this.classList.toggle('open-active')
163+
}
108164

165+
166+
}
167+
168+
panels.forEach(panel => panel.addEventListener('click', toggleOpen))
169+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive))
109170
</script>
110171

111172

112173

113174
</body>
114-
</html>
175+
176+
</html>

0 commit comments

Comments
 (0)