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
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    css image rollover effects displayed inline

    I'm using css to create dynamic rollovers of a gif image
    this is my html for that part

    Code:
    <div id="menu2"> 
    <a id ="testi" href="testimonials.html"><span>Testimonials</span></a>
    <a id ="testi" href="testimonials.html"><span>Testimonials</span></a>
    </div>
    and the css
    Code:
    #menu2 {
    	width:900px;
    	margin-left:10%;
    	}
    
    #testi
    {
      display:block;
      width:200px;
      height:100px;
      background-image:url(testimonials.gif);
      background-repeat:no-repeat;
    
    }
    #testi:hover
    { 
      background-position: 0 -100px;
    }
    #testi span
    {
      display: none;
    }
    This code makes the rollovers work fine and everything, but I can't get them to sit next to each other horizontally.

    I've tried doing
    Code:
    #menu2 a{
    	display:inline;
    	}
    but that just makes the images disappear.

    any advice?

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello Levie,
    Would float: left; and display: block; work better for you?

    If that doesn't help, link us to the test site so we can see all your code, CSS and images.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #3
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,302
    Thanks
    28
    Thanked 276 Times in 270 Posts
    Quote Originally Posted by Levie View Post
    Code:
    <div id="menu2"> 
    <a id ="testi" href="testimonials.html"><span>Testimonials</span></a>
    <a id ="testi" href="testimonials.html"><span>Testimonials</span></a>
    </div>
    A given ID can only appear once in a document. You might want to use class attributes (i.e., class="testi") and selectors (i.e., .testi and .testi:hover).

    Quote Originally Posted by Levie View Post
    I've tried doing
    Code:
    #menu2 a{
    	display:inline;
    	}
    but that just makes the images disappear.

    any advice?
    When you use display: inline, the height and width properties no longer have an effect. You might want to try display: inline-block so that height and width continue to have effect.
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #4
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Arbitrator View Post
    You might want to try display: inline-block so that height and width continue to have effect.
    This worked perfectly, thanks!!


  •  

    Posting Permissions

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