File tree 1 file changed +29
-0
lines changed
1 file changed +29
-0
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
54
60
margin : 0 ;
55
61
width : 100% ;
56
62
transition : transform 0.5s ;
63
+ flex : 1 0 auto;
64
+ display : flex;
65
+ justify-content : center;
66
+ align-items : center;
57
67
}
58
68
69
+ .panel > * : first-child { transform : translateY (-100% ); }
70
+ .panel .open-active > * : first-child { transform : translateY (0% ); }
71
+ .panel > * : last-child { transform : translateY (100% ); }
72
+ .panel .open-active > * : last-child { transform : translateY (0% ); }
73
+
59
74
.panel p {
60
75
text-transform : uppercase;
61
76
font-family : 'Amatic SC' , cursive;
67
82
}
68
83
69
84
.panel .open {
85
+ flex : 5 ;
70
86
font-size : 40px ;
71
87
}
72
88
107
123
</ div >
108
124
109
125
< script >
126
+ const panels = document . querySelectorAll ( '.panel' ) ;
127
+
128
+ function toggleOpen ( ) {
129
+ this . classList . toggle ( 'open' ) ;
130
+ }
131
+
132
+ function toggleActive ( e ) {
133
+ if ( e . propertyName . includes ( 'flex' ) ) {
134
+ this . classList . toggle ( 'open-active' ) ;
135
+ }
136
+ }
110
137
138
+ panels . forEach ( panel => panel . addEventListener ( 'click' , toggleOpen ) ) ;
139
+ panels . forEach ( panel => panel . addEventListener ( 'transitionend' , toggleActive ) ) ;
111
140
</ script >
112
141
113
142
You can’t perform that action at this time.
0 commit comments