CSS question regarding hover images

Reply

Join Date: Oct 2007
Posts: 39
Reputation: Tom Tolleson is an unknown quantity at this point 
Solved Threads: 0
Tom Tolleson's Avatar
Tom Tolleson Tom Tolleson is offline Offline
Light Poster

CSS question regarding hover images

 
0
  #1
Jan 11th, 2008
Hello!

I have a navigation bar with two tabs on a tab bar. The first represents the page being shown, and the second is a link to a second page. When the first page is being viewed, the first tab is labeled in the markup as ".current." When the second page is viewed, the second tab is is labeled in the markup is current. In the CSS file, when a tab is current, it brings up two images of a colored tab. One for the left side of the tab, and one for the right. The code in the CSS file is:

HTML and CSS Syntax (Toggle Plain Text)
  1. .tabbar_homepage li.current a {
  2. color: #fff;
  3. background: url(http://mysite.com/images/currentLeftTab.gif) no-repeat;
  4. background-position: left;
  5. }
  6.  
  7. .tabbar_homepage li.current a b {
  8. color: #fff;
  9. background: url(http://mysite.com/images/homeRightTab.gif) no-repeat;
  10. }

This works great. However, I want to do one thing further: When the other tab (for the non-current page) is moused over, I want two other tab images to come up. Here's the code I'm using:

HTML and CSS Syntax (Toggle Plain Text)
  1. .ivt a:hover {
  2. color: #fff;
  3. background: url(http://mysite.com/images/ivtLeftTab.gif) no-repeat;
  4. }
  5.  
  6. .ivt ab:hover {
  7. color: #fff;
  8. background: url(http://mysite.com/images/ivtRightTab.gif) no-repeat;
  9. }
The left side appears but no the right. I checked in the CSS guide I'm using and it says that this is correct. Does anyone have any recommendations (other than getting a new guide?)

Thanks!

THT
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 160
Reputation: JonathanD is an unknown quantity at this point 
Solved Threads: 10
Team Colleague
JonathanD's Avatar
JonathanD JonathanD is offline Offline
Marketing Consultant

Re: CSS question regarding hover images

 
0
  #2
Jan 17th, 2008
I think you need to change it to .ivt a.b:hover {... }

you're telling to select the class of ab when it's really "a" and "b" both. You might even try just using .ivt b:hover {... } and use !important to override the other class settings.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,435
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 233
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: CSS question regarding hover images

 
0
  #3
Jan 17th, 2008
  1. .tabbar_homepage li.current a b {
To explain what this is doing we have the first bit .tabbar_homepage which means that what we're going to be working with is anything with that class applied. Second is li which tells it any list-item element which that class applied, thirdly we have .current which applies ONLY to list-items within the tabbar_homepage class ie.,
  1. <div class="tabbar_homepage">
  2. <ul><li class="current">blah</li></ul>
  3. </div>
Next, we have a which will look for an anchor (a) TAG, ie., <a href="hello.html">Hello</a>. Now keep in mind that that was looking for a TAG, so when we get to the b bit it is looking for a b TAG ie., <a href="hi.html"><b>Hello</b></a> So to match that style you would need this:
  1. <!-- I'm using div as a container, doesn't matter what you use -->
  2. <div class="tabbar_homepage">
  3. <ul>
  4. <li class="current"><b><a href="test.html">Test</b></a></li>
  5. </ul>
  6. </div>
So, after all that, we realize that there is no class ab which is what you were looking for, since it is looking for the b tag inside the a tag.
Last edited by ShawnCplus; Jan 17th, 2008 at 1:44 pm.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 57
Reputation: Walkere is an unknown quantity at this point 
Solved Threads: 5
Walkere Walkere is offline Offline
Junior Poster in Training

Re: CSS question regarding hover images

 
0
  #4
Jan 19th, 2008
Originally Posted by ShawnCplus View Post
So, after all that, we realize that there is no class ab which is what you were looking for, since it is looking for the b tag inside the a tag.
And to take this one step further and answer the original question...

I'm thinking you need to change

  1. .ivt ab:hover {
to...
  1. .ivt a:hover b {

In the original example, you're looking for a <b> tag inside of an <a> tag (as Shawn pointed out). So now you want to look for a <b> tag inside of an <a> tag with the psuedo-class hover. Hence a:hover b.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 1,429
Reputation: Nichito is an unknown quantity at this point 
Solved Threads: 30
Featured Poster
Nichito's Avatar
Nichito Nichito is offline Offline
Nearly a Posting Virtuoso

Re: CSS question regarding hover images

 
0
  #5
Jan 23rd, 2008
have a similar problem: i have my #nav_bar id with a .first class, which i have originally with an image. but, i want it to change image when it's hovered on, like this:
  1. #nav_bar .first:hover
  2. {
  3. background-image:url(image2.gif);
  4. }
  1. <table cellpadding="0" cellspacing="0" id="nav_bar">
  2. <tr>
  3. <td id="first"><a href="yada yada">yada yada</a></td>
  4. </tr>
  5. </table>
but nothing happens...

am i doing something wrong?

originally i had this:
  1. #nav_bar td
  2. {
  3. background-image:url(image1.gif);
  4. }
  5.  
  6. #nav_bar td:hover
  7. {
  8. background-image:url(image2.gif);
  9. }
  1. <table cellspacing="0" cellpadding="0" id="nav_bar">
  2. <tr>
  3. <td><a href="yada yada">yada yada</a></td>
  4. </tr>
  5. </table>
and it worked perfectly, but then i added some elements at the sides of the navigation bar buttons which i don't want affected by the hover.
-->sometimes i wanna take my toaster in a bath<--
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,210
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 166
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: CSS question regarding hover images

 
0
  #6
Jan 26th, 2008
If you want your websites to be handicap-accessible, do not use hover images.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 57
Reputation: Walkere is an unknown quantity at this point 
Solved Threads: 5
Walkere Walkere is offline Offline
Junior Poster in Training

Re: CSS question regarding hover images

 
1
  #7
Jan 26th, 2008
Originally Posted by MidiMagic View Post
If you want your websites to be handicap-accessible, do not use hover images.
I think that paints the problem with far too broad a brush. Why would you have to get rid of all hover images in order to be handicap accessible?

Example. A hover image could be used to change the background of a link, simply to show that it is "hovered." Same way you would change the color of a link to show your mouse is over it. Purely visual, doesn't effect the functionality of the site. No reason it'll impair use by someone that won't be able to see the hover image.

Example. If you use a css-hover menu, you can use an alternate style sheet to make all of the links displayed, rather than not displayed until moused over.

There may be some cases where using hover images might impair the use of your website by someone using a screen reader - but there are plenty of situations where you can accommodate handicap users by making accessibility modifications.

We didn't make the world flat for people with wheelchairs. We built ramps.

- Walkere
Last edited by Walkere; Jan 26th, 2008 at 10:57 am.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,210
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 166
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: CSS question regarding hover images

 
0
  #8
Jan 28th, 2008
True. But there are more troubles than those you mention:

- It causes problems for dyslexic people. making it hard for them to read the text. The change sort of resets the perceived visual image, and the person has to start reading it again.

- It causes trouble with people using mouse trails, by erasing part of the trail. The person then sees the mouse in a position other than where it is.

- Mouse keys users also have problems.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the HTML and CSS Forum


Views: 1866 | Replies: 7
Thread Tools Search this Thread



Tag cloud for HTML and CSS
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC