9

When I expand comment body that is floated to right my container does not expand with it. How can I fix this?

Better explanation: http://jsfiddle.net/5fmpp/

Stan
  • 24,526
  • 50
  • 156
  • 238
  • Parent containers never expand to contain floated elements without additional CSS properties. – Rob Jul 31 '11 at 15:29

2 Answers2

24

Add overflow: hidden to the container so it can contain the float:

.comment
{
    width: 960px;
    margin: auto;
    margin-top: 24px;
    font-size: 14px;
    background-color: #777777;
    overflow: hidden;
}
BoltClock
  • 665,005
  • 155
  • 1,345
  • 1,328
2

Check this out.

You need to clear the float at the end of the comment box

Ahmad Alfy
  • 12,332
  • 6
  • 62
  • 95
  • 1
    Shouldn't it rather be style="clear: both;" instead of clear="both"? – MazeChaZer May 14 '14 at 19:42
  • 1
    Using clear as an HTML attribute is deprecated and has been for years. Use the solution proposed by @MazeChaZer instead. See the clear attribute reference [here](http://www.sitepoint.com/web-foundations/clear-html-attribute/) – Simon Robb Sep 16 '14 at 14:32