Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Float CSS attribute causing parent div not to inherit height?

Tags:

html

css

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?

like image 696
Zeeno Avatar asked Dec 12 '22 08:12

Zeeno


2 Answers

Set the container to overflow: hidden, and it'll wrap!

like image 70
Steve Adams Avatar answered Mar 27 '23 23:03

Steve Adams


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

like image 27
Zeeno Avatar answered Mar 27 '23 22:03

Zeeno