Posted By

terrencewood on 08/17/10


Tagged


Versions (?)

Clearing floats with CSS properties


 / Published in: CSS
 

  1. /**
  2.  * Clear floats when child elements are contained within the bounds of the selected element.
  3.  */
  4. .selected_element {overflow: hidden}
  5.  
  6. /**
  7.  * Clear floats when child elements are positioned outside the bounds of the selected element.
  8.  */
  9.  
  10. /**
  11.  * Only needed for IE6 & IE7 if hasLayout has not been triggered by some other property
  12.  * @see http://reference.sitepoint.com/css/haslayout
  13.  */
  14. .selected_element{display:inline-block}
  15.  
  16. /**
  17.  * For standards compliant browsers (including IE8+)
  18.  * "\200B" is unicode for ZERO WIDTH SPACE. Neat.
  19.  */
  20. .selected_element:after{clear:both;content:"\200B";display:block;height:0}

Report this snippet  

You need to login to post a comment.