Skip to content

Commit ad7806e

Browse files
committed
need to learn more about flex boxes
1 parent 2c48286 commit ad7806e

File tree

1 file changed

+48
-15
lines changed

1 file changed

+48
-15
lines changed

05 - Flex Panel Gallery/index-START.html

Lines changed: 48 additions & 15 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,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,8 +60,17 @@
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

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;
@@ -68,6 +83,7 @@
6883

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

7389
.cta {
@@ -80,34 +96,51 @@
8096

8197
<div class="panels">
8298
<div class="panel panel1">
83-
<p>Hey</p>
84-
<p>Let's</p>
85-
<p>Dance</p>
99+
<p>Also</p>
100+
<p>Think</p>
101+
<p>About Others</p>
86102
</div>
87103
<div class="panel panel2">
88-
<p>Give</p>
89-
<p>Take</p>
90-
<p>Receive</p>
104+
<p>Work</p>
105+
<p>Hard</p>
106+
<p>Most Days</p>
91107
</div>
92108
<div class="panel panel3">
93-
<p>Experience</p>
94-
<p>It</p>
95-
<p>Today</p>
109+
<p>Think</p>
110+
<p>About</p>
111+
<p>The World</p>
96112
</div>
97113
<div class="panel panel4">
98-
<p>Give</p>
99-
<p>All</p>
100-
<p>You can</p>
114+
<p>It's</p>
115+
<p>Your</p>
116+
<p>Future</p>
101117
</div>
102118
<div class="panel panel5">
103-
<p>Life</p>
104-
<p>In</p>
105-
<p>Motion</p>
119+
<p>The</p>
120+
<p>Future</p>
121+
<p>Is Change</p>
106122
</div>
107123
</div>
108124

109125
<script>
110126

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

113146

0 commit comments

Comments
 (0)