1

I'm trying to find the width of the scrollbar on a mobile browsers such as safari, chrome but could not figure out how.

I know there are ways to find the scrollbar width for desktop browsers, but that solution doesn't work for me. It seems clientWidth/offsetWidth/scrollWidth does not return the correct value on mobile browser.

Any help is appreciated.

Community
  • 1
  • 1
Yuan
  • 11
  • 2
  • Please read [this](http://stackoverflow.com/help/how-to-ask) and show us what you got so far. – Turing85 Apr 21 '15 at 21:25
  • The solution you found measures the scrollbar width, by forcing the scrollbar to appear, and then measuring the resulting change in width of an element. This doesn't work on mobile browsers because the scrollbar is not normally visible except when the user is actually scrolling. In addition to this, when the scrollbar does appear, it is usually rendered "on top" of the page content, and as a result the content is not resized. Normally, that means that it isn't necessary to measure the width. But since you've got a reason, what is it? – Seamus Apr 21 '15 at 22:01
  • I'm trying to add an image to the right end of the web page and the mobile browser will expand after I add the image. I thought it's because I need to leave space for the scroll bar, and need to move the image to the left a little bit. Therefore, I need to know the width of the scrollbar. BTW, I checked on chrome emulator and found the approximate width is 8 pixel. – Yuan Apr 21 '15 at 22:11

0 Answers0