Skip to content

Commit fd25895

Browse files
committed
Finishes 5 Flex Panels Image Gallery
1 parent b61861d commit fd25895

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

05 - Flex Panel Gallery/index-START.html

Lines changed: 42 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,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,26 @@
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;
67+
}
68+
69+
.panel > *:first-child {
70+
transform: translateY(-100%);
71+
}
72+
73+
.panel.open-active > *:first-child {
74+
transform: translateY(0);
75+
}
76+
77+
.panel > *:last-child {
78+
transform: translateY(100%);
79+
}
80+
81+
.panel.open-active > *:last-child {
82+
transform: translateY(0);
5783
}
5884

5985
.panel p {
@@ -67,6 +93,7 @@
6793
}
6894

6995
.panel.open {
96+
flex: 5;
7097
font-size:40px;
7198
}
7299

@@ -107,6 +134,21 @@
107134
</div>
108135

109136
<script>
137+
138+
const panels = document.querySelectorAll('.panel');
139+
140+
const toggleOpen = function() {
141+
this.classList.toggle('open');
142+
};
143+
144+
const toggleActive = function(event) {
145+
if(event.propertyName === 'flex-grow') {
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));
110152

111153
</script>
112154

0 commit comments

Comments
 (0)