im working on an horizontal scrollable container, and i need the last child to have a space from the right limit of the container when it reaches the end of the scrolling, i setted the margin right of the last child to 70px but when i finish scrolling, the right limit of the las child stucks at the right limit of the container, ignoring the margin completely. The margin IS THERE but it's ignored.
You can see it on this pen:
https://codepen.io/CarlosPisarello/pen/JQyOpB
CSS
.container {
display: flex;
flex-wrap: nowrap;
overflow-x: scroll;
overflow-y: visible;
padding-bottom: 35px;
padding-top: 35px;
width: 100%;
.card {
width: 300px;
height: 300px;
border: 1px solid red;
border-radius: 2px;
display: flex;
flex-direction: column;
align-items: center;
box-shadow: 0 15px 15px rgba(red, .3);
margin-bottom: 20px;
margin: 0 20px;
flex: 0 0 auto;
&:first-child {
margin-left: 70px;
}
&:last-child {
margin-right: 70px;
}
}
}
HTML
<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 class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
</div>