Search code examples
htmlcssmenubar

Menubar displays properly on Safari, but it's messed up on Chrome and Firefox


I'm working on a menu bar for a website but I've encountered a very weird but, and I just cannot fix it. It've spent an hour or more just working under this issue, to no effect :( The menu contains 5 links, I used a combination of unordered list and float:left links. Everything looks perfect in Safari, but in Firefox and Chrome the last link is displayed lower, as if there was a line break. I can't really use the position:absolute, because the menu is inside a container with width of 1255 pixels. Please, can someone tell me what on earth may cause the link to be displayed lower? Any ideas?
I tried deleting other components of the page and that didn't change anything, so I'm pretty sure it has to be something here:

Css:

div.menu
{
    height: 60px;
    background-image: url('2r/menu.png');
    margin-bottom: 10px;
}

ul.menu
{
    padding: 18px 0px 0px 0px;
    margin: 0;
}
ul.menu li
{
    display: inline;
    list-style-type: none;
}

a.menuitem:link
{
    float: left;
    display: block;
    padding: 0px 52px 0px 52px;
    color: #1e0c00;
    text-decoration: none;
    font-size: 22px;
    transition: background-color 0.4s, opacity 1.5s;
    -moz-transition: background-color 0.4s, opacity 1.5s;
    -webkit-transition: background-color 0.4s, opacity 1.5s;
    -o-transition: background-color 0.4s, opacity 1.5s;
}
a.menuitem:visited
{
    color: #1e0c00;
    text-decoration: none;
    font-size: 22px;
}
a.menuitem:hover 
{
    color: #441b00;
    text-decoration: none;
    font-size: 22px;
    background-color: #ffdfb6;
    opacity: 0.6;
}
a.menuitem:active
{
    color: #441b00;
    text-decoration: none;
    font-size: 22px;
}

html:

<div class="menu">
<ul class="menu">
<li><a class="menuitem" href="index.html">Xxxxxx</a></li>
<li><a class="menuitem" href="Xxxxxxx.html">Xxxxxxx Xxxxxxxxx</a></li>
<li><a class="menuitem" href="Xxxxxxxxx.html">Xxxxxxxxx</a></li>
<li><a class="menuitem" href="Xxxxxxxx.html">Xxxxxx Xxxxxxxx</a></li>
<li><a class="menuitem" href="Xxxx.html">Xxxxxxxxxx Xxxxxxxxx</a></li>
</ul>
</div>

Thank you!


Solution

  • Found it! Thanks to CBroe's suggestion, after copying only part of css code into jsfiddle, the result was good. Something else in the code caused the error, and it was because I haven't defined certain elements in ul.menu (padding-left, list-style-position) I'd defined in ul element further in the code and it "cascaded" over ul.menu causing it to act weird. Sorry about taking your time and thanks for the hint!