3 replies [Last post]
JVRudnick
JVRudnick's picture
Offline
Enthusiast
Last seen: 10 years 23 weeks ago
Timezone: GMT-4
Joined: 2004-09-22
Posts: 80
Points: 13

I've been using this little snippet to add color to a button when there is a cursor rolllover...

<style>
<!--a:hover{color:red; }-->
</style>

Question (okay, dumb one but hey I'm new to css) how can I add another color for a different button? IE I have some "special" buttons that I dont want to go red, but green instead...how?

Jim

Jim Rudnick
KKT INTERACTIVE
www.kkti.com

Tyssen
Tyssen's picture
Offline
Moderator
Brisbane
Last seen: 8 years 24 weeks ago
Brisbane
Timezone: GMT+10
Joined: 2004-05-01
Posts: 8201
Points: 1386

&lt;hover&gt; Question on color ???

You add a class to the items you want a different colour for and give it a different style, e.g.:

<div id="myDiv">
<a href="#">Link 1</a>
</div>

#myDiv a:hover { color: something else; }

or

<a class="myLink" href="#">Link 1</a>

a.myLink:hover { color: something else; }

How to get help
Post a link. If you can't post a link, jsFiddle it.
My blog | My older articles | CSS Reference

JVRudnick
JVRudnick's picture
Offline
Enthusiast
Last seen: 10 years 23 weeks ago
Timezone: GMT-4
Joined: 2004-09-22
Posts: 80
Points: 13

Um...well....um....

thanks so much....
course being the TOTAL newbie to CSS, means that i have no idea to use what you just offered.

I see that I'm to "name" a link using the <div id="myDiv"> right?

Then where do I put this --
#myDiv a:hover { color: something else; }

And thinking here, can I make multiples too? ie myDiv2 and myDiv3 could also have diff colors too, right?

Just dunno where to put that line?

Jim

Jim Rudnick
KKT INTERACTIVE
www.kkti.com

Tyssen
Tyssen's picture
Offline
Moderator
Brisbane
Last seen: 8 years 24 weeks ago
Brisbane
Timezone: GMT+10
Joined: 2004-05-01
Posts: 8201
Points: 1386

&lt;hover&gt; Question on color ???

In the examples I gave above, the first bit is the HTML, the second bit goes in your CSS file. If you're really that unclear about what you need to do, a look at a page might help to direct you better.

How to get help
Post a link. If you can't post a link, jsFiddle it.
My blog | My older articles | CSS Reference