This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do they do that?

 
ernest fakudze
Ranch Hand
Posts: 216
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I move my mouse over the links of some websites e.g. MS Website, the background of the link is highlighted in a certain colour. How is this done because I like it and I would like to experiment with it? Is it CSS??
 
Mark Herschberg
Sheriff
Posts: 6037
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm moving this to... JSP? I guess that's closest.
--Mark
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to HTML and JavaScript.
 
Michael Bronshteyn
Ranch Hand
Posts: 85
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the JavaScript. Something like "onMouseOver". Not sure exactly, but you can figure it out.
 
ernest fakudze
Ranch Hand
Posts: 216
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry sherrifs for orignally posting the msg to the wrong forum. I was day-dreaming.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it's CSS. In your onmouseover handler you can modify any CSS style (including background color).
I tried to post some code, but all the underscores and entity references in the world didn't seem to make it past the guardians, so you'll have to piece it together from the following:
To define your handler use the following attribute:

(as always, remove the underscores)
The highlight function would then be passed the element, and could do something like:

(remove spaces)
to change the background color.
You'll also want to use the on_mouse_out handler to restore the style after the mouse leaves.
Note:
1) You could create a single function and pass the new color to the function.
2) You could (this is what I would do) assign a new style class rather than a specific style to the element. That way the stylistic information is off on your style sheet rather than hard-coded in the HTML or JavaScript.
hth,
bear
 
Neil Laurance
Ranch Hand
Posts: 183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another way for the more recent browser incarnations:

Cheers, Neil
 
Amit Patel
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also you can make one file call main.css with following code
A{
font-weight : bold;
color:#ffff99;
text-decoration:none;
}
A.thin{font-weight:normal}
A:hover {
color:white;
background-color:black;
}
and on each page put this one like between <head>
<link rel="stylesheet" type="text/css" href="main.css">
That way when one day you wants to change color or style you don't have to open each page. Just open main.css and Bingo!
you can add lots of more things in this code for body backgroung and text size color and more... all from one file,
Akk the best.
-=Amit=-
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic