Skip to content

Commit 1af0ef7

Browse files
committed
Lesson 5 complete.
1 parent 6895ebd commit 1af0ef7

1 file changed

Lines changed: 41 additions & 1 deletion

File tree

05 - Flex Panel Gallery/index-START.html

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
.panels {
2525
min-height:100vh;
2626
overflow: hidden;
27+
display: flex;
2728
}
2829

2930
.panel {
@@ -41,6 +42,11 @@
4142
font-size: 20px;
4243
background-size:cover;
4344
background-position:center;
45+
flex: 1;
46+
justify-content: center;
47+
align-items: center;
48+
display: flex;
49+
flex-direction: column;
4450
}
4551

4652

@@ -54,6 +60,10 @@
5460
margin:0;
5561
width: 100%;
5662
transition:transform 0.5s;
63+
flex: 1 0 auto;
64+
display: flex;
65+
justify-content: center;
66+
align-items: center;
5767
}
5868

5969
.panel p {
@@ -62,12 +72,30 @@
6272
text-shadow:0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45);
6373
font-size: 2em;
6474
}
75+
76+
.panel > *:first-child {
77+
transform: translateY(-100%);
78+
}
79+
80+
.panel.open-active > *:first-child {
81+
transform: translateY(0);
82+
}
83+
84+
.panel > *:last-child {
85+
transform: translateY(100%);
86+
}
87+
88+
.panel.open-active > *:last-child {
89+
transform: translateY(0);
90+
}
91+
6592
.panel p:nth-child(2) {
6693
font-size: 4em;
6794
}
6895

6996
.panel.open {
7097
font-size:40px;
98+
flex: 5;
7199
}
72100

73101
.cta {
@@ -107,9 +135,21 @@
107135
</div>
108136

109137
<script>
138+
const panels = document.querySelectorAll('.panel');
110139

111-
</script>
140+
function toggleOpen() {
141+
this.classList.toggle('open');
142+
}
112143

144+
function toggleActive(event) {
145+
if (event.propertyName.includes('flex')) {
146+
this.classList.toggle('open-active');
147+
}
148+
}
149+
150+
panels.forEach(panel => panel.addEventListener('click', toggleOpen));
151+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive));
152+
</script>
113153

114154

115155
</body>

0 commit comments

Comments
 (0)