I'd like to put the maximum of Rectangle
possible within mainDiv
, and then center mainDiv
horizontally.
For example, in this image we can see eight Rectangle
within mainDiv
, but there is a space on the right side, I would like to center mainDiv
, to leave the same margin on the right side and on the left side
<div id="mainDiv" >
<div id="Rectangle" style="width: 200px; height: 300px; background: #4d5f8d; margin-left: 20px; margin-top: 30px; float: left;"></div>
<div id="Rectangle" style="width: 200px; height: 300px; background: #4d5f8d; margin-left: 20px; margin-top: 30px; float: left;"></div>
<div id="Rectangle" style="width: 200px; height: 300px; background: #4d5f8d; margin-left: 20px; margin-top: 30px; float: left;"></div>
<div id="Rectangle" style="width: 200px; height: 300px; background: #4d5f8d; margin-left: 20px; margin-top: 30px; float: left;"></div>
<div id="Rectangle" style="width: 200px; height: 300px; background: #4d5f8d; margin-left: 20px; margin-top: 30px; float: left;"></div>
<div id="Rectangle" style="width: 200px; height: 300px; background: #4d5f8d; margin-left: 20px; margin-top: 30px; float: left;"></div>
<div id="Rectangle" style="width: 200px; height: 300px; background: #4d5f8d; margin-left: 20px; margin-top: 30px; float: left;"></div>
<div id="Rectangle" style="width: 200px; height: 300px; background: #4d5f8d; margin-left: 20px; margin-top: 30px; float: left;"></div>
</div>