To achieve alignment for both elements, consider using a wrapper div to contain them and give both elements margin:auto within the wrapper. You can then apply the necessary alignment styles to the wrapper to position the first container as desired.
Another approach is to use flex display on the wrapper with flex-direction set to column and align-items to center. This way, you can specify the required alignment for the first container in relation to the wrapper class.
/*If you want the first container to be positioned 5px from the left of the window, apply these styles to the wrapper class.*/
.wrapper{
position: absolute;
left: 5px;
}
.container-1{
width: 200px;
height: 100px;
background-color: red;
margin: auto;
}
.container-2{
width: 100px;
height: 50px;
background-color: blue;
margin: auto;
}
<div class="wrapper">
<div class="container-1">First Container</div>
<div class="container-2">Second Container</div>
</div>