Page 1 of 3 123 LastLast
Results 1 to 10 of 28

Thread: Hover Effect on Buttons

  1. #1
    Join Date
    Apr 2007
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Hover Effect on Buttons

    I'm working on a project for school, and we have to have an effect on our navigation that triggers when the mouse is hovering over one of the buttons. I've already set up a hover command for other links on the page, so I'm not quite sure exactly how to go about adding the effect to the buttons.

    Please keep in mind that I'm fairly inept at CSS and HTML, so try to be specific if you have ideas.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It's fairly easy to do: simply specify the alternate style in the :hover pseudoclass.
    Code:
    .button {
      /* normal button style */
      color: red;
    }
    
    .button:hover {
      color: blue;
    }
    The only tricky bit is that for the hover effect to work in IE<7, the .button elements must be <a>s.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Apr 2007
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Essentially, that's what I want to do, however I have specific graphics I need to use. I have a graphic for the button when it's not being hovered over and one I want to use when it is being hovered over. And I apologize if the transition from what you gave me to what I want should be obvious.

  4. #4
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Code:
    .button {
      /* normal button style */
      background:url('path/to/normalImage.jpg');
    }
    
    .button:hover {
      background:url('path/to/hoverImage.jpg');
    }
    - Mike

  5. #5
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Wait a second Twey -

    Are you saying that the hover psuedo class only works in IE<=6 (JS expression)?

  6. #6
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    The hover class doesn't work in IE 6 and lower for everything besides the anchor element, you have to make annoying hacks.
    - Mike

  7. #7
    Join Date
    Apr 2007
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Right, next stupid question: I put that up with all the other CSS codes, right?

  8. #8
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Right, next stupid question: I put that up with all the other CSS codes, right?
    And yes, you do.
    - Mike

  9. #9
    Join Date
    Apr 2007
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yeah, I'm totally inept. It didn't work.

  10. #10
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    You'll need to show your source code for us to help you.
    - Mike

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •