File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-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 > * : last-child { transform : translateY (100% ); }
71
+ .panel .open-active > * : first-child { transform : translateY (0 ); }
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;
68
83
69
84
.panel .open {
70
85
font-size : 40px ;
86
+ flex : 5 ;
71
87
}
72
88
73
89
</ style >
102
118
</ div >
103
119
104
120
< script >
121
+ function panelHandleClick ( ) {
122
+ this . classList . toggle ( 'open' )
123
+ }
124
+ function panelHandleTransitionEnd ( e ) {
125
+ if ( e . propertyName !== "flex-grow" ) return
126
+ this . classList . toggle ( 'open-active' )
127
+
128
+ }
105
129
130
+ const panels = document . querySelectorAll ( '.panel' ) . forEach ( ( panel ) => {
131
+ panel . addEventListener ( 'click' , panelHandleClick ) ;
132
+ panel . addEventListener ( 'transitionend' , panelHandleTransitionEnd )
133
+ } )
106
134
</ script >
107
135
108
136
You can’t perform that action at this time.
0 commit comments