File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 2424 .panels {
2525 min-height : 100vh ;
2626 overflow : hidden;
27+ display : flex;
2728 }
2829
2930 .panel {
4142 font-size : 20px ;
4243 background-size : cover;
4344 background-position : center;
45+ flex : 1 ;
46+ justify-content : center;
47+ align-items : center;
48+ display : flex;
49+ flex-direction : column;
4450 }
4551
4652
5460 margin : 0 ;
5561 width : 100% ;
5662 transition : transform 0.5s ;
63+ flex : 1 0 auto;
64+ display : flex;
65+ justify-content : center;
66+ align-items : center;
5767 }
5868
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+
5974 .panel p {
6075 text-transform : uppercase;
6176 font-family : 'Amatic SC' , cursive;
6782 }
6883
6984 .panel .open {
85+ flex : 5 ;
7086 font-size : 40px ;
7187 }
7288
102118 </ div >
103119
104120 < script >
121+ const panels = document . querySelectorAll ( '.panel' ) ;
122+
123+ function toggleOpen ( ) {
124+ this . classList . toggle ( 'open' ) ;
125+ }
126+
127+ function toggleActive ( e ) {
128+ if ( e . propertyName . includes ( 'flex' ) ) {
129+ this . classList . toggle ( 'open-active' ) ;
130+ }
131+ }
105132
133+ panels . forEach ( panel => panel . addEventListener ( 'click' , toggleOpen ) ) ;
134+ panels . forEach ( panel => panel . addEventListener ( 'transitionend' , toggleActive ) ) ;
106135 </ script >
107136
108137
You can’t perform that action at this time.
0 commit comments