firefox & opera float background problem

Discussion in 'CSS' started by fallend, Mar 11, 2007.

  1. #1
    hello everyone

    i need to help about float problems.

    
    	<div id="lastcomment">
    	<div class="lastcommentpic"><a href="#comment-32" title="" class="slatar"><img src="avatars/20.jpg" width="50" height="50" alt="" class="lastavatar" /></a></div>
    	<div class="lastcommentpic"><a href="#comment-31" title="" class="slatar"><img src="avatars/20.jpg" width="50" height="50" alt="" class="lastavatar" /></a></div>
    	<div class="lastcommentpic"><a href="#comment-30" title="" class="slatar"><img src="avatars/18.jpg" width="50" height="50" alt="" class="lastavatar" /></a></div>
    	<div class="lastcommentpic"><a href="#comment-29" title="" class="slatar"><img src="avatars/18.jpg" width="50" height="50" alt="" class="lastavatar" /></a></div>
    	<div class="lastcommentpic"><a href="#comment-28" title="" class="slatar"><img src="avatars/18.jpg" width="50" height="50" alt="" class="lastavatar" /></a></div>
    	</div>
    
    Code (markup):
    this is my code.

    
    #lastcomment { background: url(images/sb_grey_upbg.gif) #FAFAFA repeat-x top; padding: 20px 5px 10px 6px; position: relative; width: 158px; margin: 0px; }
    
    #lastcomment img.lastavatar { height: 50px; margin: 0px; padding: 0px; width: 50px; }
    
    #lastcomment .slatar { height: 50px; margin: 0px; padding: 0px; width: 50px; }
    
    #lastcomment .lastcommentpic { float: left; height: 50px; width: 50px; margin: 1px; padding: 0px;}
    
    Code (markup):
    this is my css code.

    problem this: when i make run this codes ie ok, firefox doesnt show #lastcomment background, opera is same as firefox, i dont know how safari show it.

    can anyone help me, i want firefox to show my background when i use float.
     
    fallend, Mar 11, 2007 IP
  2. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #2
    You haven't enclosed your float elements. IE does so incorrectly when hasLayout is triggered. See my enclosing float elements demo for examples of how to do it correctly.

    It is important that you do your development in a css compliant browser such as Firefox. Else, you'll end up writing incorrect code that satisfies IE, and not realize your error. It is a simple matter to fix most of IE's buggy behavior, but it's a cast iron bitch to make bad code work in good browsers.

    cheers,

    gary
     
    kk5st, Mar 12, 2007 IP