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??
In a time of drastic change it is the learners who inherit the future. The learned usually find themselves equipped to live in a world that no longer exists.<br />Eric Hoffer
Mark Herschberg
Sheriff
Joined: Dec 04, 2000
Posts: 6037
posted
0
I'm moving this to... JSP? I guess that's closest. --Mark
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
Another way for the more recent browser incarnations:
Cheers, Neil
Amit Patel
Ranch Hand
Joined: Nov 01, 2002
Posts: 31
posted
0
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=-