I'm trying to get two side and a center for this page. After googling how to have an object in the center take the remaining width, I came across this weird problem. The center is placed down from the top, unlike the two sides. Here is the code I'm working with right now:
<html> <body> <div id="main-container"> <div class="main-left-box"> <div class="main-title"> <p class="main-title">Box #1</p> </div> <div class="main-body-center"> <p>This is box #1</p> </div> </div> <div class="main-right-box"> <div class="main-title"> <p class="main-title">Box #2</p> </div> <div class="main-body"> <p>This is box #2</p> </div> </div> <div class="main-left-box"> <div class="main-title"> <p class="main-title">Box #3</p> </div> <div class="main-body-center"> <p>This is box #3</p> </div> </div> <div class="main-center-box"> <div class="main-center-title"> <p class="main-title">Why is this not aligned with the rest?</p> </div> </div> </div> </body> <style> #main-container { width:90%; min-width:976px; background-color:grey; margin-left:auto; margin-right:auto; border-radius:5px; border:2px solid rgb(160, 160, 160); overflow:auto; padding-top:15px; } div.main-left-box { width:240px; padding:10px; margin-top:-39px; float:left; clear:left; } div.main-right-box { width:240px; padding:10px; margin-top:-39px; float:right; clear:right; } div.main-title { width:240px; height:35px; background-color:rgb(60, 60, 60); border-radius:10px; text-align:center; } p.main-title { color:white; padding-top:5px; text-decoration:underline; } div.main-body { width:220px; background-color:rgba(220, 220, 220, 0.6); margin-top:2px; border-radius:10px; padding:10px; } div.main-body-center { width:220px; background-color:rgba(220, 220, 220, 0.6); margin-top:2px; border-radius:10px; padding:10px; text-align:center; } div.main-center-box { overflow:hidden; } div.main-center-title { height:35px; background-color:rgb(60, 60, 60); border-radius:10px; text-align:center; } </style></html>
I'm not sure why it's doing this, and I can't find a good example when searching for this problem.