File tree Expand file tree Collapse file tree 1 file changed +29
-3
lines changed
Expand file tree Collapse file tree 1 file changed +29
-3
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
5056 .panel4 { background-image : url (https://source.unsplash.com/ITjiVXcwVng/1500x1500); }
5157 .panel5 { background-image : url (https://source.unsplash.com/3MNzGlQM7qs/1500x1500); }
5258
59+
60+ /* Flex Items*/
5361 .panel > * {
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 ;
7088 font-size : 40px ;
7189 }
7290
102120 </ div >
103121
104122 < script >
105-
123+ const panels = document . querySelectorAll ( '.panel' ) ;
124+ function toggleOpen ( ) {
125+ this . classList . toggle ( 'open' ) ;
126+ }
127+ function toggleActive ( e ) {
128+ if ( e . propertyName . includes ( 'flex' ) ) {
129+ this . classList . toggle ( 'open-active' ) ;
130+ }
131+ }
132+ panels . forEach ( panel => panel . addEventListener ( 'click' , toggleOpen ) ) ;
133+ panels . forEach ( panel => panel . addEventListener ( 'transitionend' , toggleActive ) ) ;
106134 </ script >
107135
108-
109-
110136</ body >
111137</ html >
You can’t perform that action at this time.
0 commit comments