Difference between Width:100% and width:100vw?

后端 未结 3 2088
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 00:31

I have to fit an iframe in screen height. Obviously, I wanted 100% as in width but, since that doesn\'t work, I used 100vh. But vh like vw is not exactly 100%. In my laptop

3条回答
  •  执念已碎
    2020-11-29 01:32

    Havengard's answer doesn't seem to be strictly true. I've found that vw fills the viewport width, but doesn't account for the scrollbars. So, if your content is taller than the viewport (so that your site has a vertical scrollbar), then using vw results in a small horizontal scrollbar. I had to switch out width: 100vw for width: 100% to get rid of the horizontal scrollbar.

提交回复
热议问题