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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Handle events thru CSS??

Status
Not open for further replies.

rwei

Programmer
Nov 19, 2004
55
US
CSS is cool, since it saves me time to define certain repetitive attributes, but can I use it to handle events?
I have a form that uses CSS to control font, color, etc. for a group of controls, but these controls also have a group of identical onmouseover and onmouseout events, how do I, or can I, 'abbreviate' the codes by using something like a CSS?
 
There is a "hover" selector that works, however currently it only works for anchors cross browser. Here is the general idea:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/strict.dtd">[/URL]

<html>
<head>
<title>new document</title>

<style type="text/css">

a {
    font-weight: bold;
    font-size: 14px;
    color: red;
}

a:hover {
    font-size: 24px;
    color: blue;
    border: 3px solid black;
}

</style>

</head>

<body>
  <a href="#">Here Is A Link</a>
</body>

</html>

*cLFlaVA
----------------------------
[tt]insert funny quotation here.[/tt]
 
Hmmm, it won't work for anything other than <A>, but I still learned something new today. I read about 'RowOver' and I now learned 'hover'. Hope to see something for 'CellOver', since I am using a <TD>.

Thanks.
 
Technically, you're not completely correct with that statement. It won't work for anything other than <a> in IE. :hover pseudo class should be available for most elements in html, unfortunately M$ neglects proper support for it. td:hover works like a charm in Mozilla. The only other thing I can think of is that you do onmouseover="this.className='one'" onmouseout="this.className='two'" and that way define everything in the class (CSS). That is about as much as you can do right now, I fear.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top