Results 1 to 7 of 7

Thread: css tab bar with *changing images* for tabs

  1. #1
    Join Date
    May 2009
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default css tab bar with *changing images* for tabs

    hey guys! I'm trying to create something like the first example on http://www.dynamicdrive.com/dynamici...tabcontent.htm ...except i would like to use images for the tabs, and have it change to another image when a particular tab is selected. The image for each tab will be different, so i have to have somewhere in my css something for each particular link ID in the links shown below...i think... I'm not exactly sure how to go about doing this.




    <ul id="tabs" class="tabs">
    <a href="#" rel="myspace" id="myspace"><img src="myspace.jpg" border=0></a>
    <a href="#" rel="facebook" id="facebook" class="selected"><img src="facebook.jpg" border=0></a>
    <a href="#" rel="gmail" id="gmail"><img src="gmail.jpg" border=0></a>
    </ul>

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Don't need the image tag. Just set the image height and width. I think this will do it...

    Code:
    #myspace {
    background:url(myspace.jpg);
    height:200px;
    width:200px;
    }
    #myspace:hover {
    background:url(myspace_mouseover.jpg);
    }

  3. #3
    Join Date
    Feb 2009
    Posts
    303
    Thanks
    18
    Thanked 36 Times in 36 Posts

    Default

    I would recommend Bluewalrus's way, but if you really need the IMG tag, use this for each of your images:
    Code:
    <img src="normal.jpg" alt="" onmouseover="this.src='hover.jpg';" onmouseout="this.src='normal.jpg';" />
    That way is very long and tedious, so I'd recommend the CSS...

    // X \\
    Alex Blackie, X96 Design
    My Website
    I specialize in: HTML5, CSS3, PHP, Ruby on Rails, MySQL, MongoDB, Linux Server Administration

  4. #4
    Join Date
    May 2009
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default first off, thank you for your replys!! i really appreciate them!

    I think those ideas are really good, but they seem like they'll only change the image when the mouse hovers over it.... What I need it to do is only change to a new image when that tab is clicked on, and stay the new image until another tab is clicked on and then revert back to the old image. Will the CSS code you provided work that way?

    I'm not at all married to using <img's > ... I don't mind using the CSS code to provide the images.

    It just needs to work like a tab menu where a specific tab changes to a new image when its active, and then when its no longer active (when someone clicks on a new tab), it goes back to the old image.

  5. #5
    Join Date
    May 2009
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    for some reason when i do this, the images seem to layer on top of one another... when i change id="myspace" to class="myspace" they no longer layer...what's the deal with that?

  6. #6
    Join Date
    May 2009
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    nevermind i figured it out :=)

  7. #7
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    ids = # are for one use per page
    classes = . are for multiple use in a page

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
  •