When an element is set to width: 100vw;
and a vertical scrollbar appears, the width of the element will include the viewport width plus the width of the scrollbar.
Is there a way to prevent this behavior?
Is it possible to avoid this without disabling horizontal scrolling for the entire page? Besides adjusting my CSS/HTML to make the element 100% of the body's width, I'm not sure what else can be done.
Tested in Chrome Version 43.0.2357.81 m & FF 36.0.1 & Opera 20.0.1387.91 on Windows 8.1
Here is the requested code:
html
<div class="parent">
<div class="box"></div>
</div>
<div class="tall"></div>
css
body { margin: 0; }
html { box-sizing: border-box; }
*, *::before, *::after {
box-sizing: inherit;
position: relative;
}
.parent {
background: rgba(0, 0, 0, .4);
height: 100px;
width: 5rem;
margin-bottom: 25px;
}
.box {
position: absolute;
top: 0;
left: 0;
background: rgba(0, 0, 0, .4);
height: 50px;
width: 100vw;
}
.tall {
height: 100rem;
}