Skip to content
This repository was archived by the owner on Feb 13, 2022. It is now read-only.

Commit e7c7c8f

Browse files
committed
solution wesbos#5
1 parent f347615 commit e7c7c8f

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

05 - Flex Panel Gallery/index-START.html

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
}
2323

2424
.panels {
25+
display: flex;
2526
min-height:100vh;
2627
overflow: hidden;
2728
}
@@ -30,6 +31,11 @@
3031
background:#6B0F9C;
3132
box-shadow:inset 0 0 0 5px rgba(255,255,255,0.1);
3233
color:white;
34+
flex: 1;
35+
justify-content: center;
36+
display: flex;
37+
flex-direction: column;
38+
align-items: center;
3339
text-align: center;
3440
align-items:center;
3541
/* Safari transitionend event.propertyName === flex */
@@ -54,6 +60,26 @@
5460
margin:0;
5561
width: 100%;
5662
transition:transform 0.5s;
63+
display: flex;
64+
justify-content: center;
65+
align-items: center;
66+
flex: 1 0 auto;
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,10 +134,18 @@
107134
</div>
108135

109136
<script>
137+
const panels = document.querySelectorAll('.panel');
110138

111-
</script>
139+
panels.forEach(panel => panel.addEventListener('click', () => {
140+
panel.classList.toggle('open');
141+
}));
112142

143+
panels.forEach(panel => panel.addEventListener('transitionend', (evt) => {
144+
if (!evt.propertyName.includes('flex')) return;
113145

146+
panel.classList.toggle('open-active');
147+
}));
148+
</script>
114149

115150
</body>
116151
</html>

0 commit comments

Comments
 (0)