#1
  1. Crypto-Con
    Devshed Supreme Being (6500+ posts)

    Join Date
    Apr 2004
    Location
    Frisco, Texas
    Posts
    6,704
    Rep Power
    1236

    CSS: apply "hover" only individual elements


    How can I apply the CSS "hover" element only to certain tags by using the "style" attribute?
    - "Cryptographically secure linear feedback shift register based stream ciphers" -- a phrase that'll get any party started.
    - Why know the ordinary when you can understand the extraordinary?
    - Sponsor my caffeine addiction! (36.70 USD received so far -- Latest donor: Mark Foxvog.
    )
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    111
    Rep Power
    12
    If you ask such a question, it's because probably you're an i.e. user.
    How to apply hover to individual elements? In theory, you do it like this:
    Code:
    To apply hover to an element, example a div:
    DIV {background-color: white}
    DIV:hover {background-color: black}
    
    To apply hover to a class, example a class "test" applied to a paragraph:
    P.test {background-color: white}
    P.test:hover {background-color: black}
    In practice, this rule is valid for all browsers (so it works on all browsers) except i.e., which supports the :hover only if applied to element A.

    So what do we do with i.e.? It's tricky, but there is a way to overcome the problem. You use the "behaviour" feature, to which you apply a jscript to do the hover bit.
    For a wonderful explanation (& script), that will solve all your problems, see: http://www.xs4all.nl/~peterned/csshover.html
    & download the script. I suggest you take a look at the source code of the above page, to see exactly how the feature is implemented. Looks complicated but it's really easy.

    Ciao
  4. #3
  5. Crypto-Con
    Devshed Supreme Being (6500+ posts)

    Join Date
    Apr 2004
    Location
    Frisco, Texas
    Posts
    6,704
    Rep Power
    1236
    Bah! One more reason to dump IE..... If it were't for the fact that Netscape has a really crappy HTML table interpretation and Opera's HTML tag interpretation in general wasn't designed by squirrels I would switch off, but I'm stuck with it...

    Thanx, I'll look at that......
    - "Cryptographically secure linear feedback shift register based stream ciphers" -- a phrase that'll get any party started.
    - Why know the ordinary when you can understand the extraordinary?
    - Sponsor my caffeine addiction! (36.70 USD received so far -- Latest donor: Mark Foxvog.
    )

IMN logo majestic logo threadwatch logo seochat tools logo