File tree 1 file changed +28
-0
lines changed
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
52
+ .panel > * : first-child { transform : translateY (-100% );}
53
+ .panel .open-active > * : first-child { transform : translateY (0 );}
54
+ .panel > * : last-child { transform : translateY (100% );}
55
+ .panel .open-active > * : last-child { transform : translateY (0 );}
46
56
47
57
.panel1 { background-image : url (https://source.unsplash.com/gYl-UtwNg_I/1500x1500); }
48
58
.panel2 { background-image : url (https://source.unsplash.com/1CD3fd8kHnE/1500x1500); }
54
64
margin : 0 ;
55
65
width : 100% ;
56
66
transition : transform 0.5s ;
67
+ flex : 1 0 auto;
68
+ display : flex;
69
+ justify-conent : center;
70
+ align-items : center;
57
71
}
58
72
59
73
.panel p {
67
81
}
68
82
69
83
.panel .open {
84
+ flex : 5 ;
70
85
font-size : 40px ;
71
86
}
72
87
107
122
</ div >
108
123
109
124
< script >
125
+ const panels = document . querySelectorAll ( '.panel' )
110
126
127
+ function toggleOpen ( ) {
128
+ this . classList . toggle ( 'open' )
129
+ }
130
+
131
+ function toggleActive ( e ) {
132
+ if ( e . propertyName . includes ( 'flex' ) ) {
133
+ this . classList . toggle ( 'open-active' )
134
+ }
135
+ }
136
+
137
+ panels . forEach ( panel => panel . addEventListener ( 'click' , toggleOpen ) )
138
+ panels . forEach ( panel => panel . addEventListener ( 'transitionend' , toggleActive ) )
111
139
</ script >
112
140
113
141
You can’t perform that action at this time.
0 commit comments