|
24 | 24 | .panels { |
25 | 25 | min-height:100vh; |
26 | 26 | overflow: hidden; |
| 27 | + display: flex; |
27 | 28 | } |
28 | 29 |
|
29 | 30 | .panel { |
| 31 | + display: flex; |
| 32 | + flex-direction: column; |
| 33 | + justify-content: center; |
| 34 | + flex: 1; |
30 | 35 | background:#6B0F9C; |
31 | 36 | box-shadow:inset 0 0 0 5px rgba(255,255,255,0.1); |
32 | 37 | color:white; |
|
43 | 48 | background-position:center; |
44 | 49 | } |
45 | 50 |
|
46 | | - |
47 | 51 | .panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); } |
48 | 52 | .panel2 { background-image:url(https://source.unsplash.com/1CD3fd8kHnE/1500x1500); } |
49 | 53 | .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); } |
|
53 | 57 | .panel > * { |
54 | 58 | margin:0; |
55 | 59 | width: 100%; |
56 | | - transition:transform 0.5s; |
| 60 | + transition: transform 0.5s cubic-bezier(0.61,-0.19, 0.7,-0.11) 0.5s; |
| 61 | + flex: 1; |
| 62 | + display: flex; |
| 63 | + justify-content: center; |
| 64 | + align-items: center; |
57 | 65 | } |
58 | 66 |
|
59 | 67 | .panel p { |
|
62 | 70 | text-shadow:0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45); |
63 | 71 | font-size: 2em; |
64 | 72 | } |
| 73 | + |
65 | 74 | .panel p:nth-child(2) { |
66 | 75 | font-size: 4em; |
67 | 76 | } |
68 | 77 |
|
69 | 78 | .panel.open { |
70 | 79 | font-size:40px; |
| 80 | + flex: 5; |
| 81 | + } |
| 82 | + |
| 83 | + .panel > *:first-child { |
| 84 | + transform: translateY(-100%); |
| 85 | + } |
| 86 | + |
| 87 | + .panel.open > *:first-child { |
| 88 | + transform: translateY(0); |
| 89 | + } |
| 90 | + |
| 91 | + .panel > *:last-child { |
| 92 | + transform: translateY(100%); |
| 93 | + } |
| 94 | + |
| 95 | + .panel.open > *:last-child { |
| 96 | + transform: translateY(0); |
71 | 97 | } |
72 | 98 |
|
73 | 99 | .cta { |
|
107 | 133 | </div> |
108 | 134 |
|
109 | 135 | <script> |
110 | | - |
| 136 | + const panels = document.querySelectorAll('.panel'); |
| 137 | + panels.forEach((panel) => ( |
| 138 | + panel.addEventListener('click', (e) => ( |
| 139 | + e.currentTarget.classList.toggle('open') |
| 140 | + )) |
| 141 | + )) |
111 | 142 | </script> |
112 | 143 |
|
113 | 144 |
|
|
0 commit comments