File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-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 {
31
+ flex : 1 ;
30
32
background : # 6B0F9C ;
31
33
box-shadow : inset 0 0 0 5px rgba (255 , 255 , 255 , 0.1 );
32
34
color : white;
41
43
font-size : 20px ;
42
44
background-size : cover;
43
45
background-position : center;
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 ;
64
+ display : flex;
65
+ align-items : center;
66
+ flex-direction : center;
67
+ justify-content : center;
68
+ }
69
+
70
+ .panel > * : first-child {
71
+ transform : translateY (-100% );
72
+ }
73
+
74
+ .panel .open-active > * : first-child {
75
+ transform : translateY (0% );
76
+ }
77
+
78
+ .panel > * : last-child {
79
+ transform : translateY (100% );
80
+ }
81
+
82
+ .panel .open-active > * : last-child {
83
+ transform : translateY (0% );
57
84
}
58
85
59
86
.panel p {
68
95
69
96
.panel .open {
70
97
font-size : 40px ;
98
+ flex : 5 ;
71
99
}
72
100
73
101
.cta {
107
135
</ div >
108
136
109
137
< script >
138
+ const panels = document . querySelectorAll ( '.panel' ) ;
139
+
140
+ function toggleOpen ( ) {
141
+ this . classList . toggle ( 'open' ) ;
142
+ }
143
+
144
+ function transitionText ( e ) {
145
+ if ( ! e . propertyName . includes ( 'flex' ) ) return ;
146
+ this . classList . toggle ( 'open-active' ) ;
147
+ }
110
148
149
+ panels . forEach ( panel => panel . addEventListener ( 'click' , toggleOpen ) ) ;
150
+ panels . forEach ( panel => panel . addEventListener ( 'transitionend' , transitionText ) ) ;
111
151
</ script >
112
152
113
153
You can’t perform that action at this time.
0 commit comments