Skip to content

Commit 2a30126

Browse files
committed
completed Flex Panel Gallery and Array Cardio Day 1
1 parent 162ad04 commit 2a30126

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

05 - Flex Panel Gallery/index-START.html

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8">
55
<title>Flex Panels 💪</title>
6-
<link href='https://fonts.googleapis.com/css?family=Amatic+SC' rel='stylesheet' type='text/css'>
6+
<link href="https://fonts.googleapis.com/css?family=Amatic+SC" rel="stylesheet" type="text/css">
77
</head>
88
<body>
99
<style>
@@ -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

@@ -50,12 +56,21 @@
5056
.panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); }
5157
.panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); }
5258

59+
/* Flex Items */
5360
.panel > * {
5461
margin:0;
5562
width: 100%;
5663
transition:transform 0.5s;
64+
flex: 1 0 auto;
65+
display: flex;
66+
justify-content: center;
67+
align-items: center;
5768
}
5869

70+
.panel > *:first-child { transform: translateY(-100%); }
71+
.panel.open-active > *:first-child { transform: translateY(0);}
72+
.panel > *:last-child { transform: translateY(100%); }
73+
.panel.open-active > *:last-child { transform: translateY(0);}
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 {
@@ -107,7 +123,19 @@
107123
</div>
108124

109125
<script>
110-
126+
const panels = document.querySelectorAll('.panel');
127+
128+
function toggleOpen() {
129+
this.classList.toggle('open');
130+
console.log('hello');
131+
}
132+
function toggleActive(e) {
133+
if(e.propertyName.includes('flex')){
134+
this.classList.toggle('open-active');
135+
}
136+
}
137+
panels.forEach(panel => panel.addEventListener('click', toggleOpen));
138+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive));
111139
</script>
112140

113141

0 commit comments

Comments
 (0)