Skip to content

Commit 12dc1f6

Browse files
committed
Course 5 done
1 parent 0c48c69 commit 12dc1f6

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

05 - Flex Panel Gallery/index-START.html

Lines changed: 39 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,24 @@
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 > *:last-child {
74+
transform: translateY(100%);
75+
}
76+
77+
.panel.open-active > *:first-child,
78+
.panel.open-active > *:last-child
79+
{
80+
transform: translateY(0);
5781
}
5882

5983
.panel p {
@@ -68,6 +92,7 @@
6892

6993
.panel.open {
7094
font-size:40px;
95+
flex: 5;
7196
}
7297

7398
</style>
@@ -102,6 +127,20 @@
102127
</div>
103128

104129
<script>
130+
const panels = document.querySelectorAll('.panel');
131+
132+
function toggleOpen(){
133+
this.classList.toggle('open');
134+
}
135+
136+
function toggleActive(e){
137+
if(e.propertyName.includes('flex')){
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));
105144

106145
</script>
107146

0 commit comments

Comments
 (0)