flexbox space-between and align right
There is a selector for that.
.container div:only-child {
margin-left: auto;
}
.container {
display: flex;
width: 300px;
justify-content: space-between;
/* Styling only */
padding: 10px;
background: #ccc;
margin-bottom: 10px;
}
.container div {
/* Styling only */
background: white;
padding: 20px 40px;
width: 10px;
}
.container div:only-child {
align-self: flex-end;
margin-left: auto;
}
<div class="container">
<div>
1
</div>
<div>
2
</div>
<div>
3
</div>
</div>
<div class="container">
<div>
3
</div>
</div>
Use flex-direction property
.container {
flex-direction:row-reverse;
}
.container {
display: flex;
width: 300px;
justify-content: space-between;
flex-direction:row-reverse;
/* Styling only */
padding: 10px;
background: #ccc;
margin-bottom: 10px;
}
.container div {
/* Styling only */
background: white;
padding: 20px 40px;
width: 10px;
}
<div class="container">
<div>
1
</div>
<div>
2
</div>
<div>
3
</div>
</div>
<div class="container">
<div>
3
</div>
</div>