Need help with a CSS issue,
I have a margin of 18px on both sides of a section on my page. However, I want to make an image (a child element) span 100% width without being affected by this margin.
Using negative margin or setting the width to 100vw doesn't give me the desired result - it either doesn't work or adds a scroll bar.
How can I make sure that the image stretches to fill the entire width of the page?
Check out an example here: https://codepen.io/astr0cd/pen/YzqXmEp
.section {
margin: 60px 18px;
}
.image {
width: 100%;
height: 400px;
margin-left: -18px;
margin-right: -18px;
object-fit: cover;
}
<div class="section">
<img src="https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__340.jpg" alt="#" class="image">
</div>