The adjacent selector is nice to use to get margin between elements in for example a card design. But how do you keep the same design when using flexbox when making responsive elements. This seems to remove the margin only of the first element and not on the first element on every line. Are there any elegant solutions for this problem? Ideally the 8 elements would look the same when they are all on one line or 4 lines.
.container {
display: flex;
flex-wrap: wrap;
}
.card {
height: 250px;
width: 250px;
background-color: blue;
}
.card+.card {
margin-left: 10px;
}
<div class="container">
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
</div>
Code also on jsbin: https://jsbin.com/cusekumiza