Forum Moderators: not2easy

Message Too Old, No Replies

Firefox Bug: unwanted space between nav bar images

         

rriggin

10:31 pm on Feb 20, 2006 (gmt 0)

10+ Year Member



Does anyone have any recommendations for this problem. I'm using the following javascript inside of a div to display 5 images vertically for a nav bar. In IE and safari, the images render fine, but in Firefox there is a large space between the images causing it to be out of line with the rest of the page.

The source code is here, along with the css style properties for the div containing the images.

<div id="maincenter">

<a href="http://www.example.com" onmouseover="image1.src='http://www.example.com/images/home1.gif';"
onmouseout="image1.src='http://www.example.com/images/home.gif';">
<img name="image1" src="http://www.example.com/images/home.gif" border=0></a>

<a href="http://www.example.com/about.html" onmouseover="image2.src='http://www.example.com/images/about1.gif';"
onmouseout="image2.src='http://www.example.com/images/about.gif';">
<img name="image2" src="http://www.example.com/images/about.gif" border=0></a>

<a href="http://www.example.com/network.html" onmouseover="image3.src='http://www.example.com/images/network1.gif';"
onmouseout="image3.src='http://www.example.com/images/network.gif';">
<img name="image3" src="http://www.example.com/images/network.gif" border=0></a>

<a href="http://www.example.com/blog" onmouseover="image4.src='http://www.example.com/images/blog1.gif';"
onmouseout="image4.src='http://www.example.com/images/blog.gif';">
<img name="image4" src="http://www.example.com/images/blog.gif" border=0></a>

<a href="mailto:info@example.com" onmouseover="image5.src='http://www.example.com/images/contact1.gif';"
onmouseout="image5.src='http://www.example.com/images/contact.gif';">
<img name="image5" src="http://www.example.com/images/contact.gif" border=0></a>
</div>

CSS:

#maincenter {
width:75px;
float:left;
background:#fff;
padding-bottom:10px;
}

I'll also include the javascript that's inserted in my <head> tag for reference:

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

image1 = new Image();
image1.src = "http://www.example.com/images/home1.gif";

image2 = new Image();
image2.src = "http://www.example.com/images/about1.gif";

image3 = new Image();
image3.src = "http://www.example.com/images/network1.gif";

image4 = new Image();
image4.src = "http://www.example.com/images/blog1.gif";

image5 = new Image();
image5.src = "http://www.example.com/images/contact1.gif";

// End -->
</script>

*I've already tried adding the following css attribute, which didn't work.

.maincenter img {
display:block;
margin:0;
padding:0;
}

Any help would be greatly appreciated.

Thanks,

rriggin

[edited by: SuzyUK at 11:34 pm (utc) on Feb. 20, 2006]
[edit reason] examplified URLs [/edit]

Robin_reala

7:40 am on Feb 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think you're seeing whitespace caused by the inline nature of the <img>s and <a>s. The simplest fix I'd suggest would be to simply remove all of the whitespace from that section of the source. Alternatively, you could make the <img>s display block and float the <a>s left - that would make them block level by default and remove any of the spacing.