You're right in saying that 100vw doesn't take into account scrollbars, and that's per spec. It's the viewport width, and whatever happens inside that viewport it doesn't care.
You could look at it the other way around: Make the default width 100%, and shunt the narrow items in from the sides.
You do, of course, run into the issue that the light grey background here doesn't extend into the margin between the items. I've hacked some compensation in here with padding, but you'll have to extend this logic to ensure padding collapses like margins do.
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
height: 100%;
}
.content {
width: 100%;
margin: 0;
overflow-y: visible;
}
.content > p {
background-color: #eee;
margin: 0;
padding: 1em 0;
}
.content > p:not(.alignfull) {
width: 400px;
margin: 0 auto;
}
.content > p.alignfull {
background: #ccc;
}
<div class="content">
<p>Some regular text. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante,
dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui.</p>
<p class="alignfull">
Some more text - should be full width. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam
lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. </p>
<p>Some regular text again. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem
ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. </p>
</div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…