Skip to content

Commit 7d6bc26

Browse files
committed
Day 5 Flex Panels Image Gallery
What’s this flex box thing? What is this css: `.panel > * {…` `.panel > *:first-child`
1 parent 50919f3 commit 7d6bc26

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

05 - Flex Panel Gallery/index-START.html

Lines changed: 31 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,6 +42,10 @@
4142
font-size: 20px;
4243
background-size:cover;
4344
background-position:center;
45+
flex: 1;
46+
justify-content:center;
47+
display: flex;
48+
flex-direction: column;
4449
}
4550

4651

@@ -54,8 +59,18 @@
5459
margin:0;
5560
width: 100%;
5661
transition:transform 0.5s;
62+
flex: 1 0 auto;
63+
display: flex:
64+
justify-content: center;
65+
align-items: center;
66+
5767
}
5868

69+
.panel > *:first-child { transform: translateY(-100%);}
70+
.panel.open-active > *:first-child { transform: translateY(0);}
71+
.panel > *:last-child { transform: translateY(100%);}
72+
.panel.open-active > *:last-child { transform: translateY(0); }
73+
5974
.panel p {
6075
text-transform: uppercase;
6176
font-family: 'Amatic SC', cursive;
@@ -67,6 +82,7 @@
6782
}
6883

6984
.panel.open {
85+
flex: 5;
7086
font-size:40px;
7187
}
7288

@@ -107,6 +123,21 @@
107123
</div>
108124

109125
<script>
126+
const panels = document.querySelectorAll('.panel');
127+
128+
function toggleOpen() {
129+
this.classList.toggle('open');
130+
}
131+
132+
function toggleActive(e) {
133+
console.log(e.propertyName);
134+
if(e.propertyName.includes('flex')){
135+
this.classList.toggle('open-active');
136+
}
137+
}
138+
139+
panels.forEach(panel => panel.addEventListener('click', toggleOpen));
140+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive));
110141

111142
</script>
112143

0 commit comments

Comments
 (0)