I have a container with a set width so its children overflow and force you to scroll. Each child element (.box) has a margin-right: 10px. The margin shows until it gets to the last element at which point it is cut off at the far right edge of the element, excluding the margin. I would like for it to show the margin for the last element, but am unable to figure out how to make this work without adding unnecessary divs to get the spacing working right, which seems like a messy solution.
The orange area should be included inside the container (red outline)
Editable codepen here: https://codepen.io/starkana/pen/wvMjdjY
.container {
display: flex;
flex-flow: row nowrap;
border: 1px solid red;
width: 170px;
overflow: scroll;
padding: 0px;
}
.box {
background: gray;
width: 40px;
height: 40px;
align-items: center;
justify-content: center;
display: flex;
margin-right: 10px !important;
flex-shrink: 0;
}
<div class="container">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
</div>
