File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-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+ /*which means that they'll evenly distribute*/
47+ justify-content : center;
48+ align-items : center;
49+ display : flex;
50+ flex-direction : column;
51+ /* nest the flex box*/
4452 }
4553
4654
5462 margin : 0 ;
5563 width : 100% ;
5664 transition : transform 0.5s ;
65+ flex : 1 0 auto;
66+ display : flex;
67+ justify-content : center;
68+ align-items : center;
5769 }
5870
71+ .panel > * : first-child { transform : translateY (-100% ); }
72+ .panel .open-active > * : first-child { transform : translateY (0 ); }
73+ .panel > * : last-child { transform : translateY (100% ); }
74+ .panel .open-active > * : last-child { transform : translateY (0 ); }
75+
5976 .panel p {
6077 text-transform : uppercase;
6178 font-family : 'Amatic SC' , cursive;
6784 }
6885
6986 .panel .open {
87+ flex : 5 ;
88+ /*flex of 5 means that when it has the class of open, it's going to be 5x the size of the rest of them*/
7089 font-size : 40px ;
7190 }
7291
107126 </ div >
108127
109128 < script >
129+ const panels = document . querySelectorAll ( '.panel' ) ;
130+ function toggleOpen ( ) {
131+ this . classList . toggle ( 'open' ) ;
132+ }
133+
134+ function toggleActive ( e ) {
135+ // console.log(e.propertyName);
136+ if ( e . propertyName . includes ( 'flex' ) ) {
137+ this . classList . toggle ( 'open-active' ) ;
138+ // this.classList.toggle('open-active');
139+ }
140+ }
141+
142+ panels . forEach ( panel => panel . addEventListener ( 'click' , toggleOpen ) ) ;
143+ panels . forEach ( panel => panel . addEventListener ( 'transitionend' , toggleActive ) ) ;
110144
111145 </ script >
112146
You can’t perform that action at this time.
0 commit comments