|
6 | 6 | --marker-radius: 50%;
|
7 | 7 | --pointer-height: 2rem;
|
8 | 8 | --pointer-width: 1rem;
|
| 9 | + --pointer-offset: 5rem; |
9 | 10 | --card-background: whitesmoke;
|
10 | 11 | --card-radius: 0.1rem;
|
11 | 12 | --card-offset: 1rem;
|
12 | 13 | --card-shadow: unset;
|
13 | 14 | --card-padding: 1rem;
|
| 15 | + --gap: 1rem; |
| 16 | + --offset-left: 0; |
| 17 | + --offset-right: 5rem; |
14 | 18 |
|
15 | 19 | position: relative;
|
16 | 20 | }
|
17 | 21 |
|
| 22 | +.timeline { |
| 23 | + display: flex; |
| 24 | +} |
| 25 | + |
18 | 26 | .timeline__line {
|
19 |
| - position: absolute; |
20 | 27 | background-color: var(--line-color);
|
21 |
| - width: var(--line-width); |
22 |
| - height: 100%; |
23 |
| - left: 50%; |
24 |
| - transform: translateX(-50%); |
| 28 | + min-width: var(--line-width); |
| 29 | +} |
| 30 | + |
| 31 | +.timeline__items-container { |
| 32 | + display: flex; |
| 33 | + flex-direction: column; |
| 34 | + gap: var(--gap); |
| 35 | + flex: 1; |
| 36 | +} |
| 37 | + |
| 38 | +.timeline__items-container--left { |
| 39 | + margin-top: var(--offset-left); |
| 40 | +} |
| 41 | + |
| 42 | +.timeline__items-container--right { |
| 43 | + margin-top: var(--offset-right); |
25 | 44 | }
|
26 | 45 |
|
27 | 46 | .timeline-item {
|
28 |
| - position: absolute; |
29 |
| - width: 50%; |
| 47 | + position: relative; |
30 | 48 | display: flex;
|
31 | 49 | align-items: flex-start;
|
32 | 50 | transition: top 0.1s;
|
33 | 51 | gap: var(--card-offset);
|
34 | 52 | }
|
35 | 53 |
|
36 |
| -.timeline-item--left { |
37 |
| - left: 0; |
| 54 | +.timeline__items-container--left .timeline-item { |
38 | 55 | flex-direction: row-reverse;
|
39 | 56 | }
|
40 | 57 |
|
41 |
| -.timeline-item--right { |
42 |
| - right: 0; |
| 58 | +.timeline-item__marker { |
| 59 | + margin-top: var(--pointer-offset); |
43 | 60 | }
|
44 | 61 |
|
45 | 62 | .timeline-item__marker:not(.timeline-item__marker--custom) {
|
|
49 | 66 | background-color: var(--marker-color);
|
50 | 67 | }
|
51 | 68 |
|
52 |
| -.timeline-item--left .timeline-item__marker { |
53 |
| - transform: translate(50%, -50%); |
| 69 | +.timeline__items-container--left .timeline-item .timeline-item__marker { |
| 70 | + transform: translate(calc(50% + var(--line-width) / 2), -50%); |
54 | 71 | }
|
55 |
| -.timeline-item--right .timeline-item__marker { |
56 |
| - transform: translate(-50%, -50%); |
| 72 | +.timeline__items-container--right .timeline-item .timeline-item__marker { |
| 73 | + transform: translate(calc(-50% - var(--line-width) / 2), -50%); |
57 | 74 | }
|
58 | 75 |
|
59 | 76 | .timeline-card {
|
|
81 | 98 | }
|
82 | 99 |
|
83 | 100 | .timeline-card__pointer {
|
84 |
| - transform: translate(100%, -50%); |
85 | 101 | position: absolute;
|
| 102 | + top: var(--pointer-offset); |
86 | 103 | }
|
87 | 104 |
|
88 | 105 | .timeline-card__pointer:not(.timeline-card__pointer--custom) {
|
|
92 | 109 | height: var(--pointer-height);
|
93 | 110 | }
|
94 | 111 |
|
95 |
| -.timeline-item--left .timeline-card__pointer { |
| 112 | +.timeline__items-container--left .timeline-item .timeline-card__pointer { |
96 | 113 | right: 0;
|
| 114 | + transform: translate(100%, -50%); |
97 | 115 | }
|
98 | 116 |
|
99 |
| -.timeline-item--right .timeline-card__pointer { |
| 117 | +.timeline__items-container--right .timeline-item .timeline-card__pointer { |
100 | 118 | transform: scaleX(-1) translate(100%, -50%);
|
101 | 119 | left: 0;
|
102 | 120 | }
|
103 | 121 |
|
104 |
| -/* left positioning */ |
105 |
| -.timeline--left .timeline__line { |
106 |
| - left: 0; |
107 |
| -} |
108 |
| - |
109 |
| -.timeline--left .timeline-item--right { |
110 |
| - left: 0; |
111 |
| - width: 100%; |
| 122 | +/* one sided positioning */ |
| 123 | +.timeline--left .timeline__items-container--left { |
| 124 | + flex: 0; |
112 | 125 | }
|
113 | 126 |
|
114 |
| -/* right positioning */ |
115 |
| -.timeline--right .timeline__line { |
116 |
| - right: 0; |
117 |
| - left: unset; |
118 |
| - transform: translateX(50%); |
119 |
| -} |
120 |
| - |
121 |
| -.timeline--right .timeline-item--left { |
122 |
| - right: 0; |
123 |
| - width: 100%; |
| 127 | +.timeline--right .timeline__items-container--right { |
| 128 | + flex: 0; |
124 | 129 | }
|
0 commit comments