Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mouse over effect 1

Status
Not open for further replies.

Craftor

Programmer
Feb 1, 2001
420
NZ
I am trying to get a mouse over effect so that my text changes color and goes bold when the user moves their mouse over a hyperlink. I can get the text change no problem but I can't seem to get the bold part right. Any thoughts?
 
what are you using as a function to change the text ? are you changing its style by changing its class (then it's more of a css problem) or by changing its style attributes (then it's more of a jscript problem) or none of those ? could you post your code here ?
 
I think they mean the link text.

try a:hover{font-weight:bold}

There is a way to have classes of these is there? it appears so, another class of hover would be:

a:hover.myClass{color:red}

So there is no need to capture mouseOver - and change classes etc, it's all done for us - yay ;)
b2 - benbiddington@surf4nix.com
 
Hi all

This is the code I am using:

<html>
<head>

<style>
a:link.1 {color: &quot;blue&quot;}
a:visited.1 {color: &quot;green&quot;}
a:hover.1 {color: &quot;red&quot;;
{font-weight: bold}}

</style>
</head>


<body>
<p><b><a class=&quot;1&quot; href=&quot;default.asp&quot; target=&quot;_blank&quot;>An example hyperlink</a></b></p>

</body>

</html>
 
Hello Craftor!
You have some serious problems in your code.

1. remove <b> tag - otherwise your link will always be bold.

2. in class naming avoid using numbers, just change &quot;1&quot; to &quot;one&quot;.

3 correct order for <a> styles is:
a. then class name one and then pseudoclass :hover

4. {color: &quot;red&quot;; {font-weight: bold}} - inner brackets for font-weight are useless. It's not an error, but cleaning up your code is a good habit.


Here is a corrected code:
Code:
<html>
<head>
<style>
a {color: blue}
a.one:visited {color: green}
a.one:hover {color: red; font-weight: bold}
</style>
</head>
<body>
<p><a class=&quot;one&quot; href=&quot;default.asp&quot; target=&quot;_blank&quot;>An example hyperlink</a></p>
</body>
</html>

It works good in IE5 (could not test in IE4) and Opera5. Netscape 6 shows hover effect, but link don't become bold. NN4.x don't recognise pseudoclasses and it doesn't work there.

Best regards,
Andrew | starway@mail.com
 
Thanks a million Andrew - felt like a bit of a moron after reading that but it WAS my first try :)-))

Works like a DREAM now!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top