|
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; |
| 50 | + |
44 | 51 | }
|
45 | 52 |
|
46 | 53 |
|
47 |
| - .panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); } |
48 |
| - .panel2 { background-image:url(https://source.unsplash.com/1CD3fd8kHnE/1500x1500); } |
49 |
| - .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); } |
50 |
| - .panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); } |
51 |
| - .panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); } |
| 54 | + .panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500);} |
| 55 | + .panel2 { background-image:url(https://source.unsplash.com/1CD3fd8kHnE/1500x1500);} |
| 56 | + .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);} |
| 57 | + .panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500);} |
| 58 | + .panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500);} |
52 | 59 |
|
53 | 60 | .panel > * {
|
54 | 61 | margin:0;
|
55 | 62 | width: 100%;
|
56 | 63 | transition:transform 0.5s;
|
| 64 | + flex: 1 0 auto; |
| 65 | + justify-content: center; |
| 66 | + align-items: center; |
| 67 | + display: flex; |
| 68 | + flex-direction: column; |
57 | 69 | }
|
58 | 70 |
|
| 71 | + .panel > *:first-child { |
| 72 | + transform: translateY(-100%); |
| 73 | + } |
| 74 | + .panel.open-active > *:first-child { |
| 75 | + transform: translateY(0); |
| 76 | + } |
| 77 | + .panel > *:last-child { |
| 78 | + transform: translateY(100%); |
| 79 | + } |
| 80 | + .panel.open-active > *:last-child { |
| 81 | + transform: translateY(0); |
| 82 | + } |
59 | 83 | .panel p {
|
60 | 84 | text-transform: uppercase;
|
61 | 85 | font-family: 'Amatic SC', cursive;
|
|
68 | 92 |
|
69 | 93 | .panel.open {
|
70 | 94 | font-size:40px;
|
| 95 | + flex: 4; |
71 | 96 | }
|
72 | 97 |
|
73 | 98 | .cta {
|
|
107 | 132 | </div>
|
108 | 133 |
|
109 | 134 | <script>
|
| 135 | + const panels = document.querySelectorAll('.panel'); |
| 136 | + console.log(panels); |
| 137 | + |
| 138 | + function toggleOpen() { |
| 139 | + this.classList.toggle('open'); |
| 140 | + }; |
| 141 | + |
| 142 | + function toggleActive(e) { |
| 143 | + console.log(e.propertyName); |
| 144 | + if (e.propertyName.includes('flex')) { |
| 145 | + this.classList.toggle('open-active'); |
| 146 | + } |
| 147 | + } |
| 148 | + |
| 149 | + panels.forEach((panel) => panel.addEventListener('click', toggleOpen)); |
| 150 | + panels.forEach((panel) => panel.addEventListener('transitionend', toggleActive)); |
| 151 | + |
110 | 152 |
|
111 | 153 | </script>
|
112 | 154 |
|
|
0 commit comments