I am facing a challenge in aligning three div elements together. My goal is to have one on the left, one in the middle, and one on the right.
However, I am encountering an issue where the middle div is not displaying correctly.
Here is my current HTML setup:
<div class="three_contents">
<div class="left">Left</div>
<div class="right">Right</div>
<div class="center">Center</div>
</div>
And here is my CSS code:
.three_contents {
width: 900px;
border: 0px solid #000;
}
.left{
float: left;
margin-top: 25px;
width: 290px;
height: 290px;}
.right{
float: right;
margin-top: 25px;
width: 290px;
height: 290px;}
.center{
display: block;
margin: 25px auto;
width: 290px;
height: 290px;}
Interestingly, when I added a 1px border to the three_contents div, the middle div suddenly aligned as expected. I have included two screenshots for reference and would appreciate any assistance in resolving this alignment issue. Thank you!
Screenshot showing the misaligned middle div:
After adding the 1px border resulting in the middle div alignment: