This question already has an answer here:
这个问题在这里已有答案:
- Height: 100% inside min-height: 100% 1 answer
身高:最小身高100%:100%1回答
Jsfiddle: http://jsfiddle.net/techsin/csfvb91u/6/
For example take a layout like this:
例如,采用这样的布局:
<div class="cont">
<div class="a"></div>
</div>
css
.a {
background-color: blue;
height: 100%;
}
.cont {
min-height: 300px;
border:1px solid;
}
I'd expect div.a to be the size of .cont which is 300px due to min-height is set as such. However, that's not what i get. .a collapses and completely ignores height 100% UNLESS .cont is explicitly set. Ex: height 300px; no min.
我希望div.a的大小为.cont,因为min-height设置为300px。但是,这不是我得到的。 .a折叠并完全忽略高度100%UNLESS .cont是明确设置的。例:身高300px;没有分钟。
Why Such flawed behavior? i need to understand reasoning.. And how can i overcome it.
为什么这种有缺陷的行为?我需要理解推理..我怎样才能克服它。
1 个解决方案
#1
2
You have to use min-height: inherit in .a class
你必须在.a类中使用min-height:inherit
.a {
background-color: blue;
min-height: inherit;
}
#1
2
You have to use min-height: inherit in .a class
你必须在.a类中使用min-height:inherit
.a {
background-color: blue;
min-height: inherit;
}