CSS:最小高度和垂直对齐:中间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5675591/
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: min-height and vertical-align:middle
提问by Somebody
How to force min-height
and vertical-align:middle
to work for td
element or it's inner element?
如何强制min-height
并vertical-align:middle
为td
元素或其内部元素工作?
回答by clairesuzy
The height
on a td
element is the equivalent of min-height
, as a table cell will always stretch if required - but note that, especially in a complex table, that setting heights on table rows is a tricky, often impossible, process, browsers have a great deal of leeway in how they render tables and will often make a "judgement call"
在height
一对td
元素的等同min-height
,因为如果需要在表格单元格将一直延伸-但要注意的是,尤其是在复杂的表格,上表中的行设置的高度是一个棘手的,往往是不可能的,过程中,浏览器有大量他们在如何呈现表格方面有余地,并且经常会做出“判断电话”
td {
height: 100px;
vertical-align:middle;
}
回答by user1875280
You can always put a div inside the td and put the css rules in the div...
你总是可以在 td 里面放一个 div 并将 css 规则放在 div 中......
回答by macloving
To force min-height attribute for td you also can put invisible image in td, or wrap you td into div. Example for first case:
要强制为 td 设置 min-height 属性,您还可以在 td 中放置不可见的图像,或者将 td 包装到 div 中。第一种情况的示例:
<td><img style="float:left;min-height:50px;visibility:hidden;width:0px;">12345</td>
回答by Edwin
margin: *;
Might do the job...
可能会做这项工作...