Search code examples
htmlcss

Float CSS attribute causing parent div not to inherit height?


I have an element in a div set to float: right however, it causes the outermost div not to wrap around. This is jsfiddle for it.

I'm trying to get the submit button to float right within the div but setting that attribute seems to cause it to break. How can I get a parent element to wrap a floated element?


Solution

  • I figured it out. The parent div should have overflow: hidden;. That will make it contain any floated elements in it.