Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Nov 2008
    Posts
    175
    Thanks
    4
    Thanked 6 Times in 6 Posts

    Making a default image

    Is there a way I can make a default image with this photo gallery.

    HTML:
    Code:
    <a href="#"><img src="images/adnlawthumb.jpg" alt="" class="thumb" /><span><img src="images/adnlaw.jpg" alt="" /></span></a>
    					<a href="#"><img src="images/ascthumb.jpg" alt="" class="thumb" /><span><img src="images/asc.jpg" alt="" /></span></a>
    					<a href="#"><img src="images/betterspecsthumb.jpg" alt="" class="thumb" /><span><img src="images/betterspecs.jpg" alt="" /></span></a>
    					<a href="#"><img src="images/coffeethumb.jpg" alt="" class="thumb" /><span><img src="images/coffee.jpg" alt="" /></span></a>
    					<a href="#"><img src="images/heartthumb.jpg" alt="" class="thumb" /><span><img src="images/heart.jpg" alt="" /></span></a>
    					<a href="#"><img src="images/r2ethumb.jpg" alt="" class="thumb" /><span><img src="images/r2e.jpg" alt="" /></span></a>
    CSS:
    Code:
    #contentLeft a span { 
        display: none; 
    } 
    
    #contentLeft a:hover span { 
    	display: block; 
        position: absolute; 
        width: 160px; 
        height: 120px; 
        top:40px; 
        left:425px; 
        border: 0; 
    }

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Add an id one you want to be the default. e.g.
    Code:
    <a href="#" id="default"><img src="images/adnlawthumb.jpg" alt="" class="thumb" /><span><img src="images/adnlaw.jpg" alt="" /></span></a>
    Then in your CSS do this
    Code:
    #contentLeft a span { 
        display: none; 
    } 
    
    #contentLeft a:hover span, #contentLeft a#default span { 
    	display: block; 
        position: absolute; 
        width: 160px; 
        height: 120px; 
        top:40px; 
        left:425px; 
        border: 0; 
    }
    The only downside is all of your images need to be the same height and width or you will see the default image all of the time.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Regular Coder
    Join Date
    Nov 2008
    Posts
    175
    Thanks
    4
    Thanked 6 Times in 6 Posts
    Thanks, that works great.

    Do you know of any way you can make it that when you hover over any image, so when you take the mouse off of it, the one you were on becomes the default one instead of the just the id="default" one?

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Not with HTML/CSS alone, no. You would need to use some javascript.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

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