Why is my sprite not displaying correctly in firefox?

I have built a css sprite for the middle navigation bar of my website. In every other browser it displays correctly – all in a neat line. However, in firefox, the final button/link is displayed slightly lower than the rest of the bar and I’m not sure why.

Here is the code I’m using:

Read More
<div id="midnavbar">
<ul id="midnav">
<li id="midnav-1"><a href="http://127.0.0.1:4001/wordpress/?page_id=13"    title="Community Connections">Community Connections</a></li>
<li id="midnav-2"><a href="http://127.0.0.1:4001/wordpress/?page_id=18 " title="Community Living">Community Living</a></li>
<li id="midnav-3"><a href="http://127.0.0.1:4001/wordpress/?page_id=118" title="Autism Spectrum">Autism Spectrum</a></li>
<li id="midnav-4"><a href="http://127.0.0.1:4001/wordpress/?page_id=123" title="Positive Support">Positive Support</a></li>
<li id="midnav-5"><a href="http://127.0.0.1:4001/wordpress/?page_id=121" title="Medically Fragile">Medically Fragile</a></li>
</ul>
</div>

css:

#midnavbar {
display:block;
}

ul#midnav {
width:955px;
height:48px;
list-style:none;
overflow:hidden;
}

ul#midnav li {
display:inline;
list-style:none;
}

ul#midnav li a {
height:48px;
float:left;
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}
ul#midnav li#midnav-1 a {
width:223px;
background: transparent url("http://127.0.0.1:4001/wordpress/wp-    content/themes/thoriumific/images/midnav.jpg") no-repeat 0 0; /* X and Y position at 0 */
}
ul#midnav  li#midnav-1 a:hover {
background-position:0 -48px; /* Y position -45px for Over instance image */
}
ul#midnav li#midnav-2 a {
width:178px;
background: transparent url("http://127.0.0.1:4001/wordpress/wp-   content/themes/thoriumific/images/midnav.jpg") no-repeat -223px 0;
}
ul#midnav  li#midnav-2 a:hover {
background-position:-223px -48px;
}
ul#midnav li#midnav-3 a {
width:179px;
background: transparent url("http://127.0.0.1:4001/wordpress/wp-content/themes/thoriumific/images/midnav.jpg") no-repeat -401px 0;
}
ul#midnav  li#midnav-3 a:hover {
background-position:-401px -48px;
}
ul#midnav li#midnav-4 a {
width:186px;
background: transparent url("http://127.0.0.1:4001/wordpress/wp-content/themes/thoriumific/images/midnav.jpg") no-repeat -580px 0;
}
ul#midnav  li#midnav-4 a:hover {
background-position:-580px -48px;
}
ul#midnav li#midnav-5 a {
width:189px;
background: transparent url("http://127.0.0.1:4001/wordpress/wp-content/themes/thoriumific/images/midnav.jpg") no-repeat -766px 0;
}
ul#midnav  li#midnav-5 a:hover {
background-position:-766px -48px;
}

I am not sure what I’m doing wrong so I don’t know how to fix it. Any suggestions would be greatly appreciated!

Related posts

Leave a Reply

1 comment

  1. You should avoid using display: inline; because it’s buggy, and as you’ve figured it out it doesn’t really work the same in all browsers. I suggest you use float: left; Also I cleaned up your css a bit.

    #midnav {
        width: 955px;
        height: 48px;
        list-style: none;
        overflow: hidden;
    }
    
    #midnav li {
        float: left;
    }
    
    #midnav a {
        height: 48px;
        display: block;
        text-indent: 100%;
        white-space: nowrap;
        overflow: hidden;
    }
    
    
    #midnav-1 a {
        width: 223px;
        background: transparent url("http://127.0.0.1:4001/wordpress/wp-    content/themes/thoriumific/images/midnav.jpg") no-repeat 0 0; /* X and Y position at 0 */
    }
    
    #midnav-1 a:hover { background-position:0 -48px }
    
    #midnav-2 a {
        width:178px;
        background: transparent url("http://127.0.0.1:4001/wordpress/wp-   content/themes/thoriumific/images/midnav.jpg") no-repeat -223px 0;
    }
    
    #midnav-2 a:hover { background-position:-223px -48px }
    
    #midnav-3 a {
        width:179px;
        background: transparent url("http://127.0.0.1:4001/wordpress/wp-content/themes/thoriumific/images/midnav.jpg") no-repeat -401px 0;
    }
    
    #midnav-3 a:hover { background-position:-401px -48px }
    
    #midnav-4 a {
        width:186px;
        background: transparent url("http://127.0.0.1:4001/wordpress/wp-content/themes/thoriumific/images/midnav.jpg") no-repeat -580px 0;
    }
    
    #midnav-4 a:hover { background-position:-580px -48px }
    
    #midnav-5 a {
        width:189px;
        background: transparent url("http://127.0.0.1:4001/wordpress/wp-content/themes/thoriumific/images/midnav.jpg") no-repeat -766px 0;
    }
    
    #midnav-5 a:hover { background-position:-766px -48px }​