Skip to content

Commit a0994ff

Browse files
committed
five complete
1 parent 69fb208 commit a0994ff

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

05 - Flex Panel Gallery/index-START.html

Lines changed: 34 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,13 @@
4142
font-size: 20px;
4243
background-size:cover;
4344
background-position:center;
45+
flex: 1;
46+
/*which means that they'll evenly distribute*/
47+
justify-content: center;
48+
align-items: center;
49+
display: flex;
50+
flex-direction: column;
51+
/* nest the flex box*/
4452
}
4553

4654

@@ -54,8 +62,17 @@
5462
margin:0;
5563
width: 100%;
5664
transition:transform 0.5s;
65+
flex: 1 0 auto;
66+
display: flex;
67+
justify-content: center;
68+
align-items: center;
5769
}
5870

71+
.panel > *:first-child { transform: translateY(-100%); }
72+
.panel.open-active > *:first-child { transform: translateY(0); }
73+
.panel > *:last-child { transform: translateY(100%); }
74+
.panel.open-active > *:last-child { transform: translateY(0); }
75+
5976
.panel p {
6077
text-transform: uppercase;
6178
font-family: 'Amatic SC', cursive;
@@ -67,6 +84,8 @@
6784
}
6885

6986
.panel.open {
87+
flex: 5;
88+
/*flex of 5 means that when it has the class of open, it's going to be 5x the size of the rest of them*/
7089
font-size:40px;
7190
}
7291

@@ -107,6 +126,21 @@
107126
</div>
108127

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

111145
</script>
112146

0 commit comments

Comments
 (0)