|
|||||||
New to SitePoint Forums? Register here for free!
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
SitePoint Zealot
![]() ![]() Join Date: Apr 2001
Location: Kapiti, New Zealand
Posts: 185
|
Change link text with :hover
Hi,
I am rebuilding http://www.justice.govt.nz/maorilandcourt/ in HTML/CSS without the Javascript and images for text. The funtionality has to be the same and the look too (as much as possible). The problem I have is that in IE, the text is not changing when I hover over the links (It is meant to change from the English to Maori, and it works in Firefox and Opera). Any help appreciated. HTML snippet Code:
<div id="faq"> <a href="faq.htm"> <img src="images/buttong.gif" width="26" height="25" alt="FAQ"> <span class="en">FAQ</span> <span class="mi">Rarangi Patai</span> </a> </div> Code:
a span.en, a:hover span.mi {
display: inline;
}
a:hover span.en, a span.mi {
display: none;
}
|
|
|
|
|
|
#2 |
|
CSS Advisor
![]() Join Date: Jan 2003
Location: Hampshire UK
Posts: 26,619
|
Hi,
This is a known bug with ie and it requires that a property must change on a:hover otherwise the span won't show. Adding this to your above code will make it work in IE: Code:
a:hover {background:#FFFFFC}
|
|
|
|
|
|
#3 |
|
SitePoint Zealot
![]() ![]() Join Date: Apr 2001
Location: Kapiti, New Zealand
Posts: 185
|
Thanks Paul O'B. Works great, and even in IE4
|
|
|
|
|
|
#4 |
|
Starting to-digg-in *********
![]() ![]() ![]() ![]() ![]() Join Date: Oct 2003
Location: Island of Puerto Rico @ the Caribbean
Posts: 883
|
Hi:
If you want more fun with the hover CSS rule. Try this: HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Playing with hover</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> a:link { text-decoration:none; } a:hover {background:#FFFFFC; background-image:url(hoverline.gif); background-position:bottom; background-repeat:repeat-x; text-decoration:none;} </style> </head> <body> <a href="http://www.ecodig.com">Use any URL here, see the nice hover decorarion.</a> </body> </html> Last edited by jamesxv7; Mar 9, 2004 at 21:03. Reason: Add the Hover image file. |
|
|
|
|
|
#5 |
|
SitePoint Member
Join Date: Sep 2006
Posts: 6
|
well, i have this problem.
i did all the coding, to change links when hovered over. except for the a.hover {background:#FFFFFC} because when i click to save changes, it changes the "#" and adds some numbers. so, instead, i changed the value slightly. but, it just shows both the text for the link, and the text for the link when it's hovered, one next to the other. here is the page i'm working on, the text in the left box is what i am having problems with. could you help me? alex. |
|
|
|
|
|
#6 | |
|
In memoriam
![]() ![]() Join Date: May 2006
Location: Aurora, Illinois
Posts: 15,648
|
Quote:
a:hover Then you'll be able to change the background color when you hover over the link. Also, don't forget to assign a color value to the rule as well, even if you only use color: inherit; instead of an actual color value. You can learn more about creating hover effects here: http://www.sitepoint.com/forums/show...79#post2957279 |
|
|
|
|
|
|
#7 |
|
Non-Member
![]() ![]() ![]() Join Date: Sep 2005
Location: UK, England
Posts: 215
|
You have IE4! - did I hear that right! :O
|
|
|
|
|
|
#8 |
|
SitePoint Member
Join Date: Sep 2006
Posts: 6
|
okay.
i don't think you got me... so i have this CSS coding: a span.sm, a:hover span.lg {display: inline; } a:hover span.sm, a span.lg {display: none; } a:hover {text-colour: 000000} and then a bit of the HTML is: <div id="aboutme"> <a href="http://"> <span class="sm">cold</span> <span class="lg">i like the cold side of the pillow</span> </a> </div> so, it's supposed to jut show "cold", and when you hover over it, it'll say "i like the cold side of the pillow" but it just shows "cold i like the cold side of the pillow". help please? |
|
|
|
|
|
#9 |
|
In memoriam
![]() ![]() Join Date: May 2006
Location: Aurora, Illinois
Posts: 15,648
|
Yup, I have Internet Explorer 3, 4, 5.01, 5.5, 6 and 7(RC1) running simultaneously on the same system without the need for a virtual machine. Only IE4 is not working, and that was only after I upgraded from IE6 to IE7RC1 as my default IE installation.
|
|
|
|
|
|
#10 |
|
In memoriam
![]() ![]() Join Date: May 2006
Location: Aurora, Illinois
Posts: 15,648
|
Well for starters, you have 374 HTML errors and at least 205 CSS errors on your page. I also saw two different layouts trying to load at the same time. You may want to take a day off, sit down and fix them all, starting with the HTML errors, then worry about the CSS.
And for the record, I tested your page in FireFox, and it took over five minutes to load. |
|
|
|
|
|
#11 |
|
SitePoint Member
Join Date: Sep 2006
Posts: 6
|
oh dear.
haha. |
|
|
|
|
|
#12 | |
|
CSS Advisor
![]() Join Date: Jan 2003
Location: Hampshire UK
Posts: 26,619
|
Quote:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
a span.sm, a:hover span.lg {display: inline; }
a:hover span.sm, a span.lg {display: none; }
a:hover {visibility:visible}
</style>
</head>
<body>
<div id="aboutme"> <a href="http://"> <span class="sm">cold</span> <span class="lg">i like the cold side of the pillow</span> </a> </div>
</body>
</html>
|
|
|
|
|
|
|
#13 |
|
SitePoint Member
Join Date: Sep 2006
Posts: 6
|
oh my god.
thank you so much just one more thing, if i have lots of links, how can i make then be next to each other? because right now theyre one underneath the other. do i need to take something out? |
|
|
|
|
|
#14 |
|
CSS Advisor
![]() Join Date: Jan 2003
Location: Hampshire UK
Posts: 26,619
|
It depends how you have organised them in the html. Links are inline elements by default and will align next to each other anyway. If you have them contained in block elements such as p tags or have made the links display:block then you will need to float them next to each other.
If you have lost of links then they should probably be contained within a list structure and then you can float the li items next to each other by applying float:left to them. (or make the list and the anchors display:inline and they should still line up alongside.) |
|
|
|
|
|
#15 |
|
SitePoint Member
Join Date: Sep 2006
Posts: 6
|
okay.
so part of it is: <div id="aboutme"> <a href="http://"> <span class="sm">cold</span> <span class="lg">i like the cold side of the pillow</span> </a> </div> <div id="aboutme"> <a href="http://"> <span class="sm">hate</span> <span class="lg">i hate anything blackcurranty</span> </a> </div> <div id="aboutme"> <a href="http://"> <span class="sm">pjs</span> <span class="lg">nighties pwn pjs</span> </a> but it shows up as cold hate pjs and i want it to say cold hate pjs anything i can do? |
|
|
|
|
|
#16 |
|
SitePoint Member
Join Date: Sep 2006
Posts: 6
|
oh, and one last thing.
i promise. how do i get the text to be black when it's hovered over? |
|
|
|
|
|
#17 |
|
CSS Advisor
![]() Join Date: Jan 2003
Location: Hampshire UK
Posts: 26,619
|
Something like this:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
ul#aboutme{
list-style:none;
margin:0;
padding:0;
}
ul#aboutme li{
display:inline;
margin-right:20px;
position:relative;
}
a span.sm, a:hover span.lg {display: inline; }
a:hover span.sm, a span.lg {display: none; }
a:hover {visibility:visible;color:#000;}
</style>
</head>
<body>
<ul id="aboutme">
<li> <a href="http://"> <span class="sm">cold</span><span class="lg">i like the cold side of the pillow</span> </a></li>
<li> <a href="http://"> <span class="sm">hate</span><span class="lg">i hate anything blackcurranty</span> </a></li>
<li><a href="http://"> <span class="sm">pjs</span><span class="lg">nighties pwn pjs</span> </a></li>
</ul>
</body>
</html>
|
|
|
|
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 06:09.











Hybrid Mode
