...

View Full Version : rollover images in divs



dubbeat
01-16-2008, 06:29 AM
Hi,
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*******//

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
<head>
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 -->
</script>
</head>

********** 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';"
onmouseout="image1.src='BUTTONS/home.png';">
<img name="image1" src="BUTTONS/home.png" border=0></a>

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

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

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

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

#nav{
position:relative;
left:500px;
width:380;
heigth:58;
}

**********************************

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!!!)

Thanks
-dub

dubbeat
01-16-2008, 06:39 AM
sorry

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

Excavator
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/)

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

Thanks!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum