Reputation: 151
My HTML code looks a bit like this, and for some reason it keeps misaligning or inserting an uncontrollable gap.
<section id="boxes">
<div id="boxes1">
<ul>
<li>Justs the Facts</li>
</ul>
</div>
<div id="boxes2">
<ul>
<li>Visit Neptune</li>
</ul>
</div>
</section>
The relevant CSS is here:
#boxes {
width:700px;
background-color: #ffffff
}
#boxes1 {
width: 350px;
float: left;
}
#boxes2 {
width: 350px;
float: right;
}
This creates something like two blocks, with a gap in between. How could I create it so that there's no margin or gap between the div section of boxes1
versus boxes2
?
Upvotes: 1
Views: 11506
Reputation: 1
#boxes1{
width: 50%;
float: left;
#boxes2 {
width: 50%;
float: left;
}
Try this...
Upvotes: 0
Reputation: 2748
This should do the needful.
#boxes{
width:700px;
background-color: #ffffff
}
#boxes1{
width: 350px;
float: left;
}
#boxes2 {
width: 350px;
float: left;
}
You can check it here:
Upvotes: 0
Reputation: 6795
you must float two boxes to the same direction, right or left.
#boxes1{
width: 350px;
float: left; /*or right*/ }
#boxes2 {
width: 350px;
float: left; /*or right*/
}
Upvotes: 0
Reputation: 35339
This is because you are floating your div
elements in opposite directions.
#boxes1 {
width: 350px;
float: left;
}
#boxes2 {
width: 350px;
float: right;
}
Float both of them to the left.
#boxes1, #boxes2 {
width: 350px;
float: left;
}
Upvotes: 0