CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 2nd, 2004, 05:26 PM
jessterk jessterk is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Brooklyn, NY
Posts: 9 jessterk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
CSS text rollovers (change the word on rollover)

I would like to create a text rollover that not only changes color but also changes the word being displayed. For example: the link on the screen would first appear to be red and would read "A". When rolled over, the link would turn black and the would read "ABOUT". I have read about transparencies and visibility, but am not sure how to impliment it. I want to keep the coding as simple as possible. Nothing is worse than too much code! Thanks.

Reply With Quote
  #2  
Old February 2nd, 2004, 05:56 PM
mad_topher mad_topher is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Milton Keynes, UK
Posts: 35 mad_topher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 43 m 57 sec
Reputation Power: 6
Place the text you want in the span section of the page and use IDs and event handlers for functions:
Code:
<span class='mouse_out' id='changeable_text' onMouseOver='show_text()' onMouseOut='hide_text()'>A</span>


Then you need the functions and styles defined in the head of the page:
Code:
<style type='text/css'>
<!--

.mouse_over {color: #000000;}
.mouse_out {color: #FF0000;}

-->
</style>

<script language='javascript' type='text/javascript'>
<!--

function show_text() {
  changeable_text.innerText = 'About';
  changeable_text.className = 'mouse_over';
}

function hide_text() {
  changeable_text.innerText = 'A';
  changeable_text.className = 'mouse_out';
}

-->
</script>

You can also add a style='cursor: hand' attribute to the span tag if you want it to look like a link... Hope that helps, it works in IE6 anyway.

Reply With Quote
  #3  
Old February 2nd, 2004, 10:19 PM
jessterk jessterk is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Brooklyn, NY
Posts: 9 jessterk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks! But I am having trouble using this script for changing more than one word on the page. How would I go about implementing this for multiple links?

Reply With Quote
  #4  
Old February 3rd, 2004, 08:55 AM
mad_topher mad_topher is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Milton Keynes, UK
Posts: 35 mad_topher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 43 m 57 sec
Reputation Power: 6
It depends on if you want exactly the same thing to happen, or if you want different text/ different coloured text displayed. If you wanted it the same, just repeat for all the links, if you wanted it for different text and CSS you could pass variables through the parentheses in the function:

Code:
<style type='text/css'>
<!--

.mouse_over {color: #000000;}
.mouse_out {color: #FF0000;}

-->
</style>

<script language='javascript' type='text/javascript'>
<!--

function show_text(text_value_over, css_class_over) {
  changeable_text.innerText = text_value_over;
  changeable_text.className = css_class_over;
}

function hide_text(text_value_out, css_class_out) {
  changeable_text.innerText = text_value_out;
  changeable_text.className = css_class_out;
}

-->
</script>


Then in the body add:

Code:
<span class='mouse_out' id='changeable_text' onMouseOver='show_text("About", "mouse_over")' onMouseOut='hide_text("A","mouse_out")'>A</span>

I haven't got time to test that right now, but as far as I can see that should work, then you can create different classes for different links and use them...

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > CSS text rollovers (change the word on rollover)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT