We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22176
    • 32 Posts
    Hi,

    Is there some way or other to change multiple images when cursering over a piece of text? My setup is as follows...

    * list item1 (this is text)
    * item 2 (all text)
    * something else (just text)
    * etc

    and there are also 3 images.

    What i want is for people to be able to cursor over the list items and for the 3 images to change with each list item.

    so it’s not quite as simple as a basic rollover image change, as with http://javascript.about.com/library/blroll1.htm, for example. I need the multiple image change.

    any help greatly appreciated.

    Olly.
      www.Guvnr.com

      .. blogging 'bout a way wider web

      Currently publishing - a 20 part video series:-

      Set Up Unmanaged VPS (4 Newbies) .. The V-P-S Bible
      • 10226
      • 412 Posts
      How about a classic rollover with animated gifs as the rollover images?

        • 27708 MODX Staff
        • 2,502 Posts
        It is possible to do it with CSS only but you have to make the list items into anchor links. Basically you load the images on the page where they can’t be seen using CSS and then use the :hover to make it visible. See the HTML and CSS below.

             <li id="pu_images">
                <a class="text" href="#text">Your Text Here
                  <span>
                         <img src="/path/to/images/image1.jpg" />
                  </span>
               </a>
        

        
        .text:hover{
        background-color: transparent;
        }
        
        
        .text span{ /*CSS for enlarged image*/
        position: absolute;
        margin:0;
        background-color: lightyellow;
        padding: 0;
        left: -1000px;
        border: 0;
        visibility: hidden;
        color: black;
        text-decoration: none;
        }
        
        .text span img{ /*CSS for enlarged image*/
        border: 0;
        padding: 2px;
        }
        
        .text:hover span{ /*CSS for enlarged image*/
        visibility: visible;
        top: 100px;
        left: 230px; /*position where enlarged image should offset horizontally */
        z-index: 50;
        }
        

        You have to make sure that the container that the absolutely positioned elements has its css position value set explicitly. In addition the container must have its z-index defined to a lower value than that of the text:hover span.



        I did something similar with images for a site recode I did for a client. It shamefully won’t validate but you can look the example here: http://novascotiaproperties.info/ . If you hover over the header images you will see a larger version of the image below.

        This replaced an arcane combination of images, javascript and a poorly written image map. Nearly 100-200 lines of code in the original HTML file. Now because it is CSS and if people come back to the site they pull everything from the cache.

        Hope this helps.

        BTW I can’t remember where I found this technique. I think I did a Google Search for "pure CSS popup image" or some such.

        Cheers,

        Jay
          Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub