2

Wondering for CSS purposes if the scroll bar is included in the viewport width? Specifically I'm thinking about calculating the sizes for img srcset. For example, would I need to account for it by subtracting like this, where the 17px is the scroll bar:

sizes="(min-width: 38em) calc(50vw-17px), calc(100vw-17px)"

I mean it's not like 17px will make any difference in the image the browser picks, but just wondering.

1
  • Just to note, the width of the scrollbar is not necessarily the same for all users.
    – MrWhite
    Commented Apr 4, 2016 at 7:51

1 Answer 1

1

In the case of desktop browsers the scrollbar isnt included in the viewport width, in mobile devices it is as the mobile device scrollbar isnt always there, only visible as a partially transparent interface. The viewport size is based on the area that the web page can actually be displayed in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.