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.

jetyet47
  • 221
  • 1
  • 2

1 Answers1

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.

Chris Rutherfurd
  • 10,191
  • 1
  • 13
  • 82