并排divs

编程入门 行业动态 更新时间:2024-10-14 02:19:36
本文介绍了并排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

本文发布于:2023-11-07 00:30:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1565063.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:divs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!