552 B
552 B
title, type, tags, cover, author, dateModified
| title | type | tags | cover | author | dateModified | |
|---|---|---|---|---|---|---|
| Scrollbar width | snippet |
|
violin | chalarangelo | 2022-07-16T05:00:00-04:00 |
Calculates the width of the window's vertical scrollbar.
- Use
Window.innerWidthto get the interior width of the window. - Use
Element.clientWidthto get the inner width of theDocumentelement. - Subtract the two values to get the width of the vertical scrollbar.
const getScrollbarWidth = () =>
window.innerWidth - document.documentElement.clientWidth;
getScrollbarWidth(); // 15