Html CSS,自动调整div的大小?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/792583/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CSS, auto resize div?
提问by khousuylong
I'm trying to design a layout with css, I got one main container(div) and two inner container(div_upper and div_lower). let say I want to resize div_upper and div_lower will automatically resize itself and both divs still fit in the main container. I'm sure this can be done in javascript, but is there any CSS to accomplish this? if so I would be glad.
我正在尝试使用 css 设计布局,我有一个主容器(div)和两个内部容器(div_upper 和 div_lower)。假设我想调整 div_upper 的大小,div_lower 将自动调整自身大小,并且两个 div 仍然适合主容器。我确定这可以在 javascript 中完成,但是有没有 CSS 来完成这个?如果是这样,我会很高兴。
采纳答案by RuudKok
Maybe this blogposton the A List Apartwebsite will help you in the right directions.
也许A List Apart网站上的这篇博文会帮助您找到正确的方向。
回答by Otabek
Another solution:
另一种解决方案:
Use this class for getting auto vertical height -
使用此类获取自动垂直高度 -
.getAutoHeight {
position: relative;
overflow: auto; /* edit by thobens: overflow: hidden seems to be better, as (at least) IE 8 shows always a disabled scrollbar with overflow: auto */
}
<div class="getAutoHeight ">
any content<br />
any content<br />
any content<br />
any content<br />
</div>
回答by paborito
CSS3 resize
:
CSS3 resize
:
.thisDiv {resize:both;}