I am currently working on creating a horizontal menu for my website. While I have made progress, I am encountering two issues that are interfering with my design.
I am exploring two potential solutions:
1). By using the following CSS:
#menu li {
display: inline-block;
}
You can view this implementation here: http://jsfiddle.net/l0ner/HPpgG/.
This method achieves the desired look, but there is unwanted white space between each element, which disrupts the design. Removing the space by placing all list elements on one line could work, but it may not be the most elegant solution.
I have considered setting the font size of the <ul>
to 0 and then restoring it in the <li>
, but it seems like a hack and goes against my preference for minimal CSS modifications.
How can I eliminate these spaces?
2). By utilizing the following CSS:
#menu li {
display: block;
float: left;
}
You can see this approach here: http://jsfiddle.net/l0ner/HPpgG/1/
However, when using this method, the <div>
container collapses, causing the white background for the menu to disappear and rendering the entire thing illegible.
Is there a way to prevent the container from collapsing?