并排divs [英] side by side divs

查看:80
本文介绍了并排divs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个父div的4个div。为了让它们并排出现,我给了所有4个div一个float:left的样式。 div并排显示,但父div的高度不会增长到包含子div的高度。我错过了什么?

I've got 4 divs inside a parent div. To get them to appear side by side, I've given all 4 divs a style with float:left. The divs do appear side by side, but the parent div's height does not grow to encompass the height of the child divs. What am I missing?

推荐答案

在4个div之后,您需要取消浮动样式。
这是通过创建ap来完成的,例如:< p style =clear:both>< / p>
您的父母div会自动获得正确的尺寸。

After the 4 divs, you need to "cancel" the float style. This is done through the creation of a p for example, like: <p style="clear: both"></p> Your parent div will automatically get the right size.

这篇关于并排divs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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