Visitar URL original
Finished Day 5 · wesbos/JavaScript30@0a1dc2e · GitHub
Skip to content

Commit 0a1dc2e

Browse files
committed
Finished Day 5
1 parent 0d807ac commit 0a1dc2e

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

‎05 - Flex Panel Gallery/index-START.html‎

Lines changed: 33 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,21 +42,38 @@
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

53+
4754
.panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); }
4855
.panel2 { background-image:url(https://source.unsplash.com/1CD3fd8kHnE/1500x1500); }
4956
.panel3 { background-image:url(https://images.unsplash.com/photo-1465188162913-8fb5709d6d57?ixlib=rb-0.3.5&q=80&fm=jpg&crop=faces&cs=tinysrgb&w=1500&h=1500&fit=crop&s=967e8a713a4e395260793fc8c802901d); }
5057
.panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); }
5158
.panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); }
5259

60+
/* Flex items */
5361
.panel > * {
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+
74+
.panel > *:last-child { transform: translateY(100%); }
75+
.panel.open-active > *:last-child { transform: translateY(0); }
76+
5977
.panel p {
6078
text-transform: uppercase;
6179
font-family: 'Amatic SC', cursive;
@@ -68,6 +86,7 @@
6886

6987
.panel.open {
7088
font-size:40px;
89+
flex: 5;
7190
}
7291

7392
.cta {
@@ -107,7 +126,21 @@
107126
</div>
108127

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

142+
panels.forEach(panel => panel.addEventListener('click', toggleOpen));
143+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive));
111144
</script>
112145

113146

0 commit comments

Comments
 (0)