SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    May 2010
    Location
    Epsom, Surrey, UK
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Multiple buttons change single remote image when hovered over - can css do it?

    Hi folks!

    I've been scouring the forums for an instance where the following has been achieved through CSS, so far with no success...

    What I'd like to set up is a navigation menu where each button changes a single remote image when hovered on.

    I've seen examples that achieve results which are similar to what I want using multiple displaced images with absolute positioning set to hidden/visible, but these are not quite what I need.

    *There should be a 'default' image in place that is visible at any time when the navigation isn't being hovered over (this hasn't been featured on any of the tutorials I found, all images have been hidden unless made visible by hovering the mouse over them).

    *The image should reflect which of the navigation buttons is being hovered on, not a simple 'on' or 'off' state for each individual button.

    *If there is any positioning used for the image, it shouldn't be absolute as the webpage it'll be implemented on is center aligned and its position on the page will vary if the screen resolution is altered, or if the browser window size is adjusted.

    It's all a bit of a tall order to satisfy criteria as exacting as this, I could probably achieve it using a multilayer code-driven Fireworks image (though I want to steer away from image-based navigation buttons) or Javascript (though I don't want the navigation to be in any way dependant on Javascript).

    If anyone out there know how this could be done and can let me know or point me to an example, I'd be very grateful!!!

    Cheers,

    Luke

  2. #2
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,888
    Mentioned
    122 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Lukasx123 View Post
    What I'd like to set up is a navigation menu where each button changes a single remote image when hovered on.

    I've seen examples that achieve results which are similar to what I want using multiple displaced images with absolute positioning set to hidden/visible, but these are not quite what I need.

    *There should be a 'default' image in place that is visible at any time when the navigation isn't being hovered over (this hasn't been featured on any of the tutorials I found, all images have been hidden unless made visible by hovering the mouse over them).

    *The image should reflect which of the navigation buttons is being hovered on, not a simple 'on' or 'off' state for each individual button.

    *If there is any positioning used for the image, it shouldn't be absolute as the webpage it'll be implemented on is center aligned and its position on the page will vary if the screen resolution is altered, or if the browser window size is adjusted.

    It's all a bit of a tall order to satisfy criteria as exacting as this, I could probably achieve it using a multilayer code-driven Fireworks image (though I want to steer away from image-based navigation buttons) or Javascript (though I don't want the navigation to be in any way dependant on Javascript).
    The best example I've seen of something like that is http://meyerweb.com/eric/css/edge/popups/demo2.html

    Although there is no default image there, you could very easily put one in the right place and set z-index:-1, so that each of the 'hover' pictures goes over the top of it.

    As for absolute positioning - that's the only way you can get the images to appear in the right place. Remember that they're absolutely positioned with respect to the parent element, rather than the page itself, so that may be of some help.

    But all in all, it sounds like you might be better off using Javascript to swap the images. This doesn't have to make the navigation inaccessible to people without JS - all it would mean is that they don't get the hover, but as long as they can still click on the menu items it should be fine.

  3. #3
    SitePoint Member
    Join Date
    May 2010
    Location
    Epsom, Surrey, UK
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your reply Stevie!

    I'll check out that link, and have a closer look at using a Javascript method to build the navigation.

  4. #4
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,367
    Mentioned
    180 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    As Stevie said if you want persistence and function then you need to add js to achieve this.

    You can easily change an image as in this (very old) example and as Stevie also mentioned the image is placed absolutely in relation to a main parent and will therefore move with the page and stay in place.

    It might help if you have a drawing of the kind of thing you are looking for so we can be more specific


Tags for this Thread

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
  •