Forum Moderators: not2easy

Message Too Old, No Replies

Hover effect not working, weird validation errors too

Some CSS code won't validate, but I don't see an error

         

peterdouglas

9:57 pm on Jun 20, 2005 (gmt 0)

10+ Year Member



I'm trying to get a hover effect on a logo that also is a link back to the home page. So far, the link works, but the hover doesn't. I have two images, one lighter and one darker. (the hover state is the darker one).

I've been using CSS for a few months and can usually fix any errors, but this has me baffled. If anyone could explain what these errors mean, that would be great. I followed some good CSS code examples, as this was rather complex. There are a few lines of CSS code that won't validate:

* Line: 45 Context : #logoban

Parse Error - (images/banner1.gif) no-repeat;
* Line: 50

Parse Error - : 600px; height: 50px; } a#logoban:hover
* Line: 51

Parse error - Unrecognized : (images/banner2.gif) no-repeat;
* Line: 52

Parse error - Unrecognized : }

peterdouglas

10:37 pm on Jun 20, 2005 (gmt 0)

10+ Year Member



Well, I found the problems with the validation errors... I took out the space between URL and ( but my hover effect still isn't working.

It might be kind of hard to pinpoint exactly what is is, but basically I have a logo that when hovered on, will switch to a brighter version of the same logo. It also doubles up as a link back to the index page.

Here's part of the code:

<div id="newmenu"><div id="bannerlogoban"><a id="logoban" href="index.html">

/* Image-free logo banner with rollover */
#bannerlogoban {
background: url(images/banner2.gif) no-repeat;
}

#logoban {
background: url(images/banner1.gif) no-repeat;
}

a#logoban:hover {
background: url(images/banner2.gif) no-repeat;
}

(margins, padding, etc omitted). Is it just me, or am I missing something? No matter what I try, the hover effect on the logo just won't work.

D_Blackwell

12:01 am on Jun 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here is one way to go:

<head>
<style>
#logoban {
background-image: url(abc.jpg); width: Xpx; height: Ypx;
}
#logoban a {
display: block; width: Xpx; height: Ypx; text-decoration: none;
}
#logoban a:hover {
display: block; background-image: url(acb.jpg);
}
</style>
</head>
</body>
<div id="logoban">
<a href="">
</a>
</div>
</body>

Depending upon the situation, you might consider preloading the hovered image in the head. It might not look too good if it pops into place several seconds after the hover.

<object type="image/jpeg" data="acb.jpg"></object>

<edit>Not leaving well enough alone:)</edit>

D_Blackwell

12:26 am on Jun 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Perhaps better to move the first image here:

#logoban a {
display: block; width: 300px; height: 400px; background-image: url(abc.jpg);
}

IE seems a bit quirky otherwise.

peterdouglas

1:19 am on Jun 21, 2005 (gmt 0)

10+ Year Member



Thanks, I got it working now, even in IE6 for Windows! Yes, it was kind of quirky, something to do with spaces again. Looks best in Firefox (Mac and PC), but most people will see it in IE...