Home › Forums › CSS › Background not expanding with my gallery › Re: Background not expanding with my gallery
Whenever you float elements within a containing element, the containing element WILL COLLAPSE unless you do one of the following:
1) Float the containing element as well. However, this will not ensure that the containing element interacts properly with other elements on the page.
2) You clear the floated elements. This can be done by adding an empty element such as a div or li tag after the other elements with "clear:left" applied using CSS. This clearing element must be INSIDE of the containing element. Otherwise, the containing element will collapse.
If you haven’t watched Chris’ screencast #42: All About Floats, please do so! It is a great episode covering floats and how to work with them.
Another thought about your page: you are currently floating the img tags. Keep in mind that floating is easier when you apply it to the TOPMOST element that needs to float. In this case, it would be better to apply it to the li elements that contain the image tags, not the actual img tags themselves.
Anyway, hope that helps!