Skip to content

Commit 0abc392

Browse files
finished 5
1 parent f154ab2 commit 0abc392

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

05 - Flex Panel Gallery/index-START.html

Lines changed: 28 additions & 0 deletions
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,8 +42,17 @@
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

52+
.panel > *:first-child { transform: translateY(-100%);}
53+
.panel.open-active > *:first-child { transform: translateY(0);}
54+
.panel > *:last-child { transform: translateY(100%);}
55+
.panel.open-active > *:last-child { transform: translateY(0);}
4656

4757
.panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); }
4858
.panel2 { background-image:url(https://source.unsplash.com/1CD3fd8kHnE/1500x1500); }
@@ -54,6 +64,10 @@
5464
margin:0;
5565
width: 100%;
5666
transition:transform 0.5s;
67+
flex: 1 0 auto;
68+
display: flex;
69+
justify-conent: center;
70+
align-items: center;
5771
}
5872

5973
.panel p {
@@ -67,6 +81,7 @@
6781
}
6882

6983
.panel.open {
84+
flex: 5;
7085
font-size:40px;
7186
}
7287

@@ -107,7 +122,20 @@
107122
</div>
108123

109124
<script>
125+
const panels = document.querySelectorAll('.panel')
110126

127+
function toggleOpen() {
128+
this.classList.toggle('open')
129+
}
130+
131+
function toggleActive(e) {
132+
if(e.propertyName.includes('flex')) {
133+
this.classList.toggle('open-active')
134+
}
135+
}
136+
137+
panels.forEach(panel => panel.addEventListener('click', toggleOpen))
138+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive))
111139
</script>
112140

113141

0 commit comments

Comments
 (0)