Can a div expand to 100vw
within a parent div that is relative
and has a limited width, without losing its height in the document like it would if positioned absolute?
Is it achievable with pure CSS or do I need some jQuery or JS?
body {
background: #f0f0f0;
text-align: center;
}
.parent {
max-width: 300px;
height: 300px;
margin: auto;
position: relative;
background: white;
}
p {
padding: 20px;
}
#banner {
padding: 20px;
background: black;
color: white;
}
<div class="parent">
<p>My relative parent container,<br>with a fixed width.</p>
<div id="banner">
My full width banner
</div>
<p>...</p>
</div>
Has anyone successfully implemented this? Any tips or guidance would be greatly appreciated. Thank you!