Reputation: 399
I am very simply trying to have 5 Divs inline, inside a div. I am doing this by simply creating a div, and inside that div having 5 divs with the widths of 20% each, all using inline-block.
However, all im getting is 4 of my divs in the parent div and the 5th overflowing onto the next line.
How could this be happening? 5 x 20 = 100%, so why does it seem to equal more?
http://pastebin.com/uS6vcwTM HTML code
http://pastebin.com/VKHS7swJ CSS code
Upvotes: 0
Views: 67
Reputation: 207891
Inline elements are sensitive to white space. You can remove the white space between the divs like:
<div id="Navigation">
<div class="NavButton">Button</div><div class="NavButton">Button</div><div class="NavButton">Button</div><div class="NavButton">Button</div><div class="NavButton">Button</div>
</div>
Or add float:left
to the NavButton
class.
Upvotes: 3
Reputation: 114990
Inline-block
takes account of whitespace in your HTML.
This usually equates to .0.25em or 4px depending on your browsers basic font-size.
There are a couple of techniques to solve this.
The first and perhaps simplest involves setting the font size of the parent to 0. The font size would then need to be reset in the children...the boxes
Upvotes: 2