CSS高度:100%问题 [英] CSS Height:100% issue

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

问题描述

我试图让div wrapper 包围它内部的所有div,这取决于内容的数量高度 wrapper 会增长。



我猜这样做的方法是设置 height:100%,但正如你从下面的屏幕截图中看到的那样,情况并非如此。



它说'No :-('是 height:100%在理想情况下,我希望 wrapper 位于底部,它表示'是',我画了一个红色



任何帮助都是非常值得赞赏的。

如果你使用浮动,给容器溢出:隐藏可能会解决这个问题。如果没有固定的大小给div,这使得它延伸到浮动元素。



如果你有绝对定位在内部的元素e容器,很高兴看到解决方案的html / css。


I'm trying to get the div wrapper to surround all the divs within it so depending on the amount of content the height of wrapper will grow.

I guessed that the way of doing this would be to set height: 100% but as you can see from the screen grab below, this is not the case.

Where it says 'No :-(' is what having height: 100% is doing where ideally I would like wrapper to be at the bottom where it says 'Yes' and I have drawn a red line.

Any help is much appreciated.

解决方案

If you are using floats, giving the container overflow:hidden might fix the problem. If no fixed size is given to the div, this makes it stretch over the floated elements.

If you have absolutely positioned elements inside the container, it would be good to see the html/css for a solution.

这篇关于CSS高度:100%问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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