View Full Version : rollover images in divs

01-16-2008, 06:29 AM
Im brand new to css and I building a small site to teach my self.

I have 2 problems hindering my progress and I think they may be related.

First off is my problem with rollover buttons for navigation. (might belong in the javascript forum)

I have four images that I am using as button. These buttons are contained in a div tag inside of a header div.

If I rollover a button, instead of seeing its over state the buttons flicker, disappear and swap positions!!! I'm very new to this and am bewildered.

//*********** javascript in head*******//


<!-- Begin
image1 = new Image();
image1.src = "BUTTONS/home_over.png";

image2 = new Image();
image2.src = "BUTTONS/services_over.png";

image3 = new Image();
image3.src = "BUTTONS/portfolio_over.png";

image4 = new Image();
image4.src = "BUTTONS/contact_over.png";

// End -->

********** the div tag html*****************
<div id="top">
<div id="logo"> </div>
<div id="nav">

<a href="index.html" onmouseover="image1.src='images/BUTTONS/home_over.png';"
<img name="image1" src="BUTTONS/home.png" border=0></a>

<a href="services.html" onmouseover="image2.src='images/BUTTONS/services_over.png';"
<img name="image2" src="BUTTONS/services.png" border=0></a>

<a href="portfolio.html" onmouseover="image3.src='images/BUTTONS/portfolio_over.png';"
<img name="image3" src="BUTTONS/portfolio.png" border=0></a>

<a href="contact.html" onmouseover="image4.src='images/BUTTONS/contact_over.png';"
<img name="image4" src="BUTTONS/contact.png" border=0></a></div>

********** the css class*************



The java script was generated free online so I expected it to "just work".

Because it doesn't I started thinking it had something to do with the div that the images were in. Maybe each image needs a different div??

My main concern about these navigation buttons in the header is fluidity. I have a floating content box on the right hand side of the screen. I really want the site to shrink together when a screen is minimized. This works fine for the content box but Im not sure how or if its possible to achieve with these buttons i'm using.

The code I posted probably looks horrific, but I only really started a couple of days ago.

Any advice or tips are really really welcome.

P.s.... I attached a zip file containing my files. Its just a single html page and a css file and a few images. (please dont laugh if you look at it!!!)


01-16-2008, 06:39 AM

please ignore the previously attached zip file. Its the wrong one. I have attached the right one here

01-16-2008, 09:40 AM
Hello dubbeat,
I'm not a big fan of js menus or rollovers. Have a look at a couple CSS only examples I have. Look at the source and the images to see how it's done.
one (http://nopeople.com/CSS/CSS_rollover/)
two (http://nopeople.com/CSS/2state%20CSS%20navbar/)
three (http://nopeople.com/doodlebug/)

01-16-2008, 10:08 AM
working examples to study are cool!
I'll take a look,