1
1
<!DOCTYPE html>
2
2
< html lang ="en ">
3
+
3
4
< head >
4
5
< meta charset ="UTF-8 ">
5
6
< title > Flex Panels 💪</ title >
6
7
< link href ='https://fonts.googleapis.com/css?family=Amatic+SC ' rel ='stylesheet ' type ='text/css '>
7
8
</ head >
9
+
8
10
< body >
9
11
< style >
10
12
html {
11
13
box-sizing : border-box;
12
- background : # ffc600 ;
13
- font-family : 'helvetica neue' ;
14
+ background : # ffc600 ;
15
+ font-family : 'helvetica neue' ;
14
16
font-size : 20px ;
15
17
font-weight : 200 ;
16
18
}
19
+
17
20
body {
18
21
margin : 0 ;
19
22
}
20
- * , * : before , * : after {
23
+
24
+ * ,
25
+ * : before ,
26
+ * : after {
21
27
box-sizing : inherit;
22
28
}
23
29
24
30
.panels {
25
- min-height : 100vh ;
31
+ min-height : 100vh ;
26
32
overflow : hidden;
27
33
display : flex;
28
34
}
29
35
30
36
.panel {
31
- background : # 6B0F9C ;
32
- box-shadow : inset 0 0 0 5px rgba (255 , 255 , 255 , 0.1 );
33
- color : white;
37
+ flex : 1 ;
38
+ background : # 6B0F9C ;
39
+ box-shadow : inset 0 0 0 5px rgba (255 , 255 , 255 , 0.1 );
40
+ color : white;
34
41
text-align : center;
35
- align-items : center;
42
+ align-items : center;
36
43
/* Safari transitionend event.propertyName === flex */
37
44
/* Chrome + FF transitionend event.propertyName === flex-grow */
38
- transition :
39
- font-size 0.7s cubic-bezier (0.61 , -0.19 , 0.7 , -0.11 ),
40
- flex 0.7s cubic-bezier (0.61 , -0.19 , 0.7 , -0.11 ),
41
- background 0.2s ;
45
+ transition : font-size 0.7s cubic-bezier (0.61 , -0.19 , 0.7 , -0.11 ),
46
+ flex 0.7s cubic-bezier (0.61 , -0.19 , 0.7 , -0.11 ),
47
+ background 0.2s ;
42
48
font-size : 20px ;
43
- background-size : cover;
44
- background-position : center;
45
- flex : 1 ;
46
- justify-content : center;
49
+ background-size : cover;
50
+ background-position : center;
47
51
display : flex;
48
52
flex-direction : column;
49
53
}
50
54
51
55
52
- .panel1 { background-image : url (https://source.unsplash.com/gYl-UtwNg_I/1500x1500); }
53
- .panel2 { background-image : url (https://source.unsplash.com/rFKUFzjPYiQ/1500x1500); }
54
- .panel3 { background-image : url (https://images.unsplash.com/photo-1465188162913-8fb5709d6d57?ixlib=rb-0.3.5&q=80&fm=jpg&crop=faces&cs=tinysrgb&w=1500&h=1500&fit=crop&s=967e8a713a4e395260793fc8c802901d); }
55
- .panel4 { background-image : url (https://source.unsplash.com/ITjiVXcwVng/1500x1500); }
56
- .panel5 { background-image : url (https://source.unsplash.com/3MNzGlQM7qs/1500x1500); }
56
+ .panel1 {
57
+ background-image : url (https://source.unsplash.com/gYl-UtwNg_I/1500x1500);
58
+ }
59
+
60
+ .panel2 {
61
+ background-image : url (https://source.unsplash.com/rFKUFzjPYiQ/1500x1500);
62
+ }
63
+
64
+ .panel3 {
65
+ background-image : url (https://images.unsplash.com/photo-1465188162913-8fb5709d6d57?ixlib=rb-0.3.5&q=80&fm=jpg&crop=faces&cs=tinysrgb&w=1500&h=1500&fit=crop&s=967e8a713a4e395260793fc8c802901d);
66
+ }
57
67
58
- /* Flex Items */
59
- .panel > * {
60
- margin : 0 ;
68
+ .panel4 {
69
+ background-image : url (https://source.unsplash.com/ITjiVXcwVng/1500x1500);
70
+ }
71
+
72
+ .panel5 {
73
+ background-image : url (https://source.unsplash.com/3MNzGlQM7qs/1500x1500);
74
+ }
75
+
76
+ .panel > * {
77
+ margin : 0 ;
61
78
width : 100% ;
62
- transition : transform 0.5s ;
79
+ transition : transform 0.5s ;
63
80
flex : 1 0 auto;
64
- display : flex;
65
- justify-content : center;
66
- align-items : center;
81
+ display : flex;
82
+ }
83
+
84
+ .panel > * : first-child {
85
+ transform : translateY (-100% )
86
+ }
87
+
88
+ .panel > * : last-child {
89
+ transform : translateY (+100% )
90
+ }
91
+
92
+ .panel .open-active > * {
93
+ transform : translateY (0 )
67
94
}
68
95
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
96
74
97
.panel p {
75
98
text-transform : uppercase;
76
99
font-family : 'Amatic SC' , cursive;
77
- text-shadow : 0 0 4px rgba (0 , 0 , 0 , 0.72 ), 0 0 14px rgba (0 , 0 , 0 , 0.45 );
100
+ text-shadow : 0 0 4px rgba (0 , 0 , 0 , 0.72 ), 0 0 14px rgba (0 , 0 , 0 , 0.45 );
78
101
font-size : 2em ;
102
+ justify-content : center;
103
+ align-items : center;
79
104
}
105
+
80
106
.panel p : nth-child (2 ) {
81
107
font-size : 4em ;
82
108
}
83
109
84
110
.panel .open {
85
111
flex : 5 ;
86
- font-size : 40px ;
112
+ font-size : 40px ;
87
113
}
88
-
89
114
</ style >
90
115
91
116
121
146
const panels = document . querySelectorAll ( '.panel' ) ;
122
147
123
148
function toggleOpen ( ) {
124
- console . log ( 'Hello' ) ;
125
149
this . classList . toggle ( 'open' ) ;
126
150
}
127
-
128
151
function toggleActive ( e ) {
129
- console . log ( e . propertyName ) ;
130
152
if ( e . propertyName . includes ( 'flex' ) ) {
131
153
this . classList . toggle ( 'open-active' ) ;
132
154
}
133
155
}
134
156
135
157
panels . forEach ( panel => panel . addEventListener ( 'click' , toggleOpen ) ) ;
136
158
panels . forEach ( panel => panel . addEventListener ( 'transitionend' , toggleActive ) ) ;
159
+
137
160
</ script >
138
161
162
+
163
+
139
164
</ body >
140
- </ html >
165
+
166
+ </ html >
0 commit comments