Results 1 to 2 of 2

Thread: Pure CSS rollover images

  1. #1
    Join Date
    May 2008
    Posts
    5
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Post Pure CSS rollover images

    Hey everyone. I've seen alot of examples for CSS rollovers that utilize a background image change but I'm going for something more graphically intense and i'm looking to create links that mouseover but trying to do so without employing text.

    here is the current version using javascript, which i am trying to replace with pure css:

    http://www.alimahamani.com


    Any help?

    Thanks,
    Brian

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    For that you would use the hover pseudo class and a background image change. The link would need to be display:block and set to the dimensions of the image, loosely:

    Code:
    a#anch1 {
    background-image:url(some.gif);
    width:90px;
    height:35px;
    display:block;
    }
    
    a#anch1:hover {
    background-image:url(some_other.gif);
    }
    It's true that its more efficient if you use text over a plain image, that way there is very little in the way of images that need to be cached by the user. But you can use pairs of images, one pair for each link for a more intricate or dramatic look. Images can be preloaded without javascript by putting img tags for them on the page in a hidden division positioned absolutely off to the top and left of the window.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    midevilb (05-21-2008)

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
  •