File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
2-ui/1-document/09-size-and-scroll/2-scrollbar-width Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 1- To get the scrollbar width, we can create an element with the scroll, but without borders and paddings .
1+ Щоб отримати ширину смуги прокрутки, ми можемо створити елемент із прокруткою, але без рамок і відступів .
22
3- Then the difference between its full width ` offsetWidth ` and the inner content area width ` clientWidth ` will be exactly the scrollbar :
3+ Тоді різниця між його повною шириною ` offsetWidth ` і шириною внутрішньої області вмісту ` clientWidth ` буде саме ширина смуги прокрутки :
44
55``` js run
6- // create a div with the scroll
6+ // створюємо div з прокруткою
77let div = document .createElement (' div' );
88
99div .style .overflowY = ' scroll' ;
1010div .style .width = ' 50px' ;
1111div .style .height = ' 50px' ;
1212
13- // must put it in the document, otherwise sizes will be 0
13+ // потрібно розмістити його в документі, інакше розміри будуть 0
1414document .body .append (div);
1515let scrollWidth = div .offsetWidth - div .clientWidth ;
1616
You can’t perform that action at this time.
0 commit comments