/    Sign up×
Community /Pin to ProfileBookmark

Mouseover effect

Hi there.

I got this code:

<span style=”text-align: center; color: #ffffff; font-size: 12px; background-color: #0065cd; width: 158px; height: 22px;”>home</span>

I want to make it that way so when the mouse is over the SPAN the background color and the font color are different. How can I do it?

Thanks!

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@FangAug 27.2004 — A true css [I]hover[/I] can only be achieved on a link element, see [URL=http://www.webdeveloper.com/forum/showthread.php?s=&threadid=42910]thread[/URL]

The alternative is to use JavaScript [I]mouseover/mouseout[/I].
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;title&gt;Basic rollover&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
&lt;style type="text/css"&gt;
&lt;!--
.out {
text-align: center;
color: #ffffff;
font-size: 12px;
background: #0065cd;
width: 158px;
height: 22px;
}
.over {
background:#f00;
}
--&gt;
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p class="out" onmouseover="this.className='over';" onmouseout="this.className='out';"&gt;home&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@VladdyAug 27.2004 — [i]Originally posted by Fang [/i]

[B]A true css [I]hover[/I] can only be achieved on a link element, see [URL=http://www.webdeveloper.com/forum/showthread.php?s=&threadid=42910]thread[/URL]

<snip/>

[/B]
[/QUOTE]

CSS :hover pseudo-class can be applied to any element (that is displayed). The problem is with IE implementing the :hover for links only. And for that there is a much simpler fix: www.vladdy.net/Demos/iepseudoclassesfix.html
×

Success!

Help @weee spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...