简体   繁体   English

重叠的Divs-如何环绕?

[英]Overlapping Divs — How to Wrap Around?

I got a large div that is containing several dynamic divs inside of it. 我有一个大的div,里面包含几个动态div。

They are often padded to the left and inside another div that is also padded left. 它们经常被填充到左侧和另一个也被填充的div内部。

What I'm trying to do is have the overall containing div (it has a border) look inside these children divs and find how big it needs to expand itself in order to look like it's "containing" all its children. 我正在尝试做的是在这些子div的内部使包含div的整体(带有边框)看上去,并发现它需要扩展多大才能使其“包含”所有子div。

Any ideas on a nice elegant way to do this? 有什么想法以优雅的方式做到这一点? Right now I've got some hobbled together combination of finding the large div in question, finding its length and adding on all the -left-padding of its parents. 现在我有一些步履蹒跚的组合,找到有问题的大div,找到它的长度,并添加其父母的所有-left-padding。

just set the css property, overflow:hidden; 只需设置css属性, overflow:hidden; on your "overall containing div". 在您的“总体包含div”上。 That'll make it automatically expand to contain all the stuff inside it. 这将使其自动扩展以包含其中的所有内容。

You could use a CSS clearfix . 您可以使用CSS clearfix This is ideal for floating the contents inside a container. 这是将内容浮动到容器内的理想选择。 Just save the code to clearfix.css and link to that in your html. 只需将代码保存到clearfix.css并链接到您的html中即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM