File tree 1 file changed +29
-3
lines changed
1 file changed +29
-3
lines changed Original file line number Diff line number Diff line change 24
24
.panels {
25
25
min-height : 100vh ;
26
26
overflow : hidden;
27
+ display : flex;
27
28
}
28
29
29
30
.panel {
41
42
font-size : 20px ;
42
43
background-size : cover;
43
44
background-position : center;
45
+ flex : 1 ;
46
+ justify-content : center;
47
+ align-items : center;
48
+ display : flex;
49
+ flex-direction : column;
44
50
}
45
51
46
52
50
56
.panel4 { background-image : url (https://source.unsplash.com/ITjiVXcwVng/1500x1500); }
51
57
.panel5 { background-image : url (https://source.unsplash.com/3MNzGlQM7qs/1500x1500); }
52
58
59
+
60
+ /* Flex Items*/
53
61
.panel > * {
54
62
margin : 0 ;
55
63
width : 100% ;
56
64
transition : transform 0.5s ;
65
+ flex : 1 0 auto;
66
+ display : flex;
67
+ justify-content : center;
68
+ align-items : center;
57
69
}
58
70
71
+ .panel > * : first-child {transform : translateY (-100% );}
72
+ .panel .open-active > * : first-child {transform : translateY (0% );}
73
+ .panel > * : last-child {transform : translateY (100% );}
74
+ .panel .open-active > * : last-child {transform : translateY (0% );}
75
+
59
76
.panel p {
60
77
text-transform : uppercase;
61
78
font-family : 'Amatic SC' , cursive;
67
84
}
68
85
69
86
.panel .open {
87
+ flex : 5 ;
70
88
font-size : 40px ;
71
89
}
72
90
102
120
</ div >
103
121
104
122
< script >
105
-
123
+ const panels = document . querySelectorAll ( '.panel' ) ;
124
+ function toggleOpen ( ) {
125
+ this . classList . toggle ( 'open' ) ;
126
+ }
127
+ function toggleActive ( e ) {
128
+ if ( e . propertyName . includes ( 'flex' ) ) {
129
+ this . classList . toggle ( 'open-active' ) ;
130
+ }
131
+ }
132
+ panels . forEach ( panel => panel . addEventListener ( 'click' , toggleOpen ) ) ;
133
+ panels . forEach ( panel => panel . addEventListener ( 'transitionend' , toggleActive ) ) ;
106
134
</ script >
107
135
108
-
109
-
110
136
</ body >
111
137
</ html >
You can’t perform that action at this time.
0 commit comments