two-up { display: grid; position: relative; --split-point: 0; --track-color: rgb(0 0 0 / 0.6); --thumb-background: var(--black); --thumb-color: var(--accent-color); --thumb-size: 62px; --bar-size: 9px; --bar-touch-size: 30px; } two-up > * { /* Overlay all children on top of each other, and let two-up's layout contain all of them. */ grid-area: 1/1; } two-up[legacy-clip-compat] > :not(.two-up-handle) { /* Legacy mode uses clip rather than clip-path (Edge doesn't support clip-path), but clip requires elements to be positioned absolutely */ position: absolute; } .two-up-handle { touch-action: none; position: relative; width: var(--bar-touch-size); transform: translateX(var(--split-point)) translateX(-50%); will-change: transform; cursor: ew-resize; } .two-up-handle::before { content: ''; display: block; height: 100%; width: var(--bar-size); margin: 0 auto; background: var(--track-color); } .scrubber { display: grid; align-content: center; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: var(--thumb-size); height: var(--thumb-size); background: var(--thumb-background); border-radius: var(--thumb-size); color: var(--thumb-color); box-sizing: border-box; padding: 0 calc(var(--thumb-size) * 0.24); } .arrow-left { fill: var(--pink); } .arrow-right { fill: var(--blue); } two-up[orientation='vertical'] .two-up-handle { width: auto; height: var(--bar-touch-size); transform: translateY(var(--split-point)) translateY(-50%); cursor: ns-resize; } two-up[orientation='vertical'] .two-up-handle::before { width: auto; height: var(--bar-size); box-shadow: inset 0 calc(var(--bar-size) / 2) 0 rgba(0, 0, 0, 0.1), 0 1px 4px rgba(0, 0, 0, 0.4); margin: calc((var(--bar-touch-size) - var(--bar-size)) / 2) 0 0 0; } two-up[orientation='vertical'] .scrubber { box-shadow: 1px 0 4px rgba(0, 0, 0, 0.1); transform: translate(-50%, -50%) rotate(-90deg); } two-up > :nth-child(1):not(.two-up-handle) { -webkit-clip-path: inset(0 calc(100% - var(--split-point)) 0 0); clip-path: inset(0 calc(100% - var(--split-point)) 0 0); } two-up > :nth-child(2):not(.two-up-handle) { -webkit-clip-path: inset(0 0 0 var(--split-point)); clip-path: inset(0 0 0 var(--split-point)); } two-up[orientation='vertical'] > :nth-child(1):not(.two-up-handle) { -webkit-clip-path: inset(0 0 calc(100% - var(--split-point)) 0); clip-path: inset(0 0 calc(100% - var(--split-point)) 0); } two-up[orientation='vertical'] > :nth-child(2):not(.two-up-handle) { -webkit-clip-path: inset(var(--split-point) 0 0 0); clip-path: inset(var(--split-point) 0 0 0); } /* Even in legacy-clip-compat, prefer clip-path if it's supported. It performs way better in Safari. */ @supports not ( (clip-path: inset(0 0 0 0)) or (-webkit-clip-path: inset(0 0 0 0)) ) { two-up[legacy-clip-compat] > :nth-child(1):not(.two-up-handle) { clip: rect(auto var(--split-point) auto auto); } two-up[legacy-clip-compat] > :nth-child(2):not(.two-up-handle) { clip: rect(auto auto auto var(--split-point)); } two-up[orientation='vertical'][legacy-clip-compat] > :nth-child(1):not(.two-up-handle) { clip: rect(auto auto var(--split-point) auto); } two-up[orientation='vertical'][legacy-clip-compat] > :nth-child(2):not(.two-up-handle) { clip: rect(var(--split-point) auto auto auto); } }