浮动CSS属性导致父div不继承高度? [英] Float CSS attribute causing parent div not to inherit height?

查看:330
本文介绍了浮动CSS属性导致父div不继承高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在div中将一个元素设置为 float:对,但是,这导致最外面的div不回绕。这是 jsfiddle

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正在尝试使提交按钮在div内浮动,但是设置该属性似乎会导致其中断。

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?

推荐答案

我知道如何解决这个问题。父div应该具有溢出:隐藏; 。这将使其包含任何浮动元素。

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

这篇关于浮动CSS属性导致父div不继承高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆