Aligning a Block Element with Right Indent in CSS
If necessary, you can also set a right indent and the element will not be pressed close to the right border, but will move away from it:
<div class="parent">
<div class="child"></div>
</div>
.parent {
padding: 10px 0;
border: 1px solid red;
}
.child {
margin-left: auto;
margin-right: 20px; /* set the right indent */
height: 100px;
width: 200px;
border: 1px solid green;
}
: