I have a container with a maximum width of 1024px, and I want one of its child elements to take up 100% width starting from the left edge of the screen.
Is there a way to achieve this without adding extra HTML markup? I know I can make the child element 100% width using width: 100vw;
, but I'm having trouble aligning it to the left.
Here's my current CSS:
.parent {
max-width: 800px;
margin: 0 auto;
}
.child {
margin-top: 20px;
padding: 20px;
width: 100vw;
background: grey;
}
<div class="parent">
<a href="#" class="toggle">Toggle content</a>
<div class="child">Content</div>
</div>
You can see the issue in action on this CodePen link.