A zig-zag timeline where entries alternate between the left and right column, without a single :nth-child() rule. Each entry reads its own position with sibling-index(), and mod(sibling-index(), 2) turns that into 1 or 0. Subtracting it from 2 gives column 1 for odd entries and column 2 for even ones. The same index sets the grid row, so a shorthand like grid-area: sibling-index() / var(--column) puts each entry on its own row and side. The connector dot uses the same 0-or-1 value to move to whichever edge faces the center line. Browsers without sibling-index() fall back to a plain single-column list through @supports.
HTML
<ol class="timeline">
<li class="entry"><time>2019</time><p>Project kicks off</p></li>
<li class="entry"><time>2021</time><p>First public beta</p></li>
<li class="entry"><time>2023</time><p>Version 1.0 ships</p></li>
<li class="entry"><time>2024</time><p>Plugin system lands</p></li>
<li class="entry"><time>2026</time><p>Ten thousand users</p></li>
</ol>CSS
body { font-family: system-ui, sans-serif; margin: 1.5rem; background: #fff; color: #111827; }
.timeline {
list-style: none;
margin: 0;
padding: 0;
display: grid;
gap: 0.5rem;
}
.entry {
position: relative;
padding: 0.5rem 0.75rem;
border: 1px solid #e5e7eb;
border-radius: 8px;
background: #eff6ff;
}
.entry time { font-size: 0.75rem; font-weight: 700; color: #2563eb; }
.entry p { margin: 0.15rem 0 0; font-size: 0.85rem; }
/* Only switch to the two-sided layout where sibling-index() works */
@supports (order: sibling-index()) {
.timeline {
grid-template-columns: repeat(2, minmax(0, 1fr));
column-gap: 2rem;
row-gap: 0.25rem;
/* Center line running between the two columns */
background: linear-gradient(#93c5fd, #93c5fd) center / 2px 100% no-repeat;
}
.entry {
/* Odd entries: 2 - 1 = column 1. Even entries: 2 - 0 = column 2. */
--column: calc(2 - mod(sibling-index(), 2));
/* 0 for the left column, 1 for the right */
--side: calc(var(--column) - 1);
grid-area: sibling-index() / var(--column);
}
/* Dot on the edge facing the center line */
.entry::before {
content: "";
position: absolute;
top: 0.8rem;
left: calc((1 - var(--side)) * 100% + 1rem - var(--side) * 2rem - 6px);
width: 12px;
height: 12px;
border-radius: 50%;
background: #2563eb;
box-shadow: 0 0 0 3px #fff;
}
}