I am trying to remove outer left and right margins on the first and last items in a row of flex items. Using nth()
isn't an option since the first and last in a row will be dynamic depending on screen size. The only option I found for the below code was to add a negative margin to the container:
margin-left: -30px;
margin-right: -30px;
but that feels "hacky". Are there are any other solutions?
body, html {
background: grey;
height: 100%;
}
.container {
display: flex;
height: 100%;
flex-wrap: wrap;
justify-content: center;
align-content: center;
align-items: center;
}
.container div {
height: 60px;
flex: 1 1 600px;
background: green;
margin: 20px;
}
<div class="container">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>