CSS 如何降低div高度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22498843/
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
how to reduce the div height
提问by shas
<div class="row-fluid" >
<div class="span6">
<div class="control-group checkForError">
<label class="control-label" for="Client">Client</label>
<div class="controls">
<input style="height: 100px" type="text" name="Client" id="Client" readonly="readonly"
class="m-wrap span4 clrField" tabindex="1">
<input type="text" name="name" id="name" readonly="readonly"
class="m-wrap span8 clrField" tabindex="2">
</div>
</div>
</div>
</div>
Now I want to reduce the div height.
现在我想降低 div 高度。
I am tried with min-height but its not reduces.
我尝试过 min-height 但它没有减少。
If I increase height it is increasing.
如果我增加高度,它就会增加。
Pls help me
请帮助我
回答by Bhojendra Rauniyar
You need to use max-height not min-height!
您需要使用最大高度而不是最小高度!
div{
max-height: 100px;
height: 100%;
}
回答by Tushar Narang
use max-height instead. It will work fine. the min- height wont work on div.
改用最大高度。它会正常工作。最小高度不适用于 div。
回答by user3432064
<div class="row-fluid" style="height:100px">
..............
..........
</div>
回答by Kevin
A div's height depends on its inner elements, in your example, the first input is having a height of 100px, so the div will have at least 100px height, ignoring spacing, boarder, padding. Setting max-height on the div will hint the rendering engine to limit the height, but doesn't necessarily work all the time.
div 的高度取决于其内部元素,在您的示例中,第一个输入的高度为 100px,因此 div 的高度至少为 100px,忽略间距、边界、填充。在 div 上设置 max-height 会提示渲染引擎限制高度,但不一定一直有效。
I'd suggest you changing the input's height first:
我建议你先改变输入的高度:
<input style="max-height: 100px" type="text" name="Client" id="Client" readonly="readonly" class="m-wrap span4 clrField" tabindex="1" />