Seeking guidance on using CSS to center Block 2 in the space to the right of Block 1, which may vary in size based on the browser window or device orientation. Block 1 remains fixed in its position.
Considering using float, margin-left:auto, and margin-right:auto to achieve the desired centering effect for Block 2, but my CSS skills are still evolving.
Any assistance or suggestions would be highly appreciated.
#block1 {
position:relative;
top:10px;
left:0px;
width:50px;
height:100px;
background-color:#009;
}
#block2 {
position:relative;
width:100px;
height:100px;
top:10px;
float:right;
margin-left:auto;
margin-right:auto;
background-color:#999;
}
<div id="block1"></div>
<div id="block2"></div>
Appreciating your help in advance