Skip to content

Commit 2a70640

Browse files
author
Jin Xu
committed
course wesbos#5 finished
1 parent 8e83e79 commit 2a70640

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

05 - Flex Panel Gallery/index-START.html

+33-3
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,10 @@
4142
font-size: 20px;
4243
background-size:cover;
4344
background-position:center;
45+
flex: 1;
46+
display: flex;
47+
will-change: transform;
48+
flex-direction: column;
4449
}
4550

4651

@@ -61,13 +66,34 @@
6166
font-family: 'Amatic SC', cursive;
6267
text-shadow:0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45);
6368
font-size: 2em;
69+
flex: 1;
70+
align-items: center;
71+
justify-content: center;
72+
display: flex;
73+
transition: transform .7s ease-in;
6474
}
75+
.panel p:nth-child(1) {
76+
transform: translateY(-100%);
77+
}
78+
.panel p:nth-child(3) {
79+
transform: translateY(100%);
80+
}
81+
6582
.panel p:nth-child(2) {
6683
font-size: 4em;
6784
}
6885

6986
.panel.open {
7087
font-size:40px;
88+
flex: 5;
89+
}
90+
91+
.panel.open p:nth-child(1) {
92+
transform: translateY(0);
93+
}
94+
95+
.panel.open p:nth-child(3) {
96+
transform: translateY(0);
7197
}
7298

7399
.cta {
@@ -107,10 +133,14 @@
107133
</div>
108134

109135
<script>
110-
136+
document.querySelectorAll('.panel').forEach(panel => {
137+
// evt binding
138+
panel.addEventListener('click', e => {
139+
document.querySelectorAll('.panel').forEach(item => item.classList.remove('open'))
140+
panel.classList.add('open')
141+
}, false)
142+
})
111143
</script>
112144

113-
114-
115145
</body>
116146
</html>

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
2. [x] ~~JS + CSS Clock~~
99
3. [x] ~~CSS Variables~~
1010
4. [x] ~~Array Cardio, Day 1~~
11-
5. [ ] Flex Panel Gallery
11+
5. [x] ~~Flex Panel Gallery~~
1212
6. [ ] Type Ahead
1313
7. [ ] Array Cardio, Day 2
1414
8. [ ] Fun with HTML5 Canvas

0 commit comments

Comments
 (0)