| |
Web developers have long struggled with centering divs, but modern CSS (using `display: grid` and `place-items: center`) made it trivial—until browsers added sidebars and DevTools that broke the centering by shifting the viewport. The author developed a solution using pointer events and viewport coordinates to detect the actual screen position and adjust for browser UI elements on either side, even accounting for DevTools being open. They created a tool called "center, actually" that can apply this fix to any webpage to properly center elements regardless of browser chrome interference.
Read Full Article →
← More Tech news