I have a component that allows cards to stack on top of one another. This snippet below is a simplified version of a top row of cards.
The cards must ALWAYS be the same width, and there needs to be 16px gap between the cards, this has been made possible by padding of 8px on both the left & right of each card.
However, I do not want any gap on the outer left and right of the cards (they should sit tight against the viewport). Removing padding however in this way then allows the other cards to grow in size. How can I remove the padding-left on the first card, the padding-right on the last card whilst ensuring all cards remain the same width?
body {
margin: 0;
}
.wrapper {
display: flex;
}
.card-container {
padding-left: 8px;
padding-right: 8px;
flex: 0 0 auto;
width: 25%;
}
.card-container .card-content {
height: 150px;
width: 100%;
background-color: lightblue;
}
<div class="wrapper">
<div class="card-container">
<div class="card-content"></div>
</div>
<div class="card-container">
<div class="card-content"></div>
</div>
<div class="card-container">
<div class="card-content"></div>
</div>
<div class="card-container">
<div class="card-content"></div>
</div>
</div>