[英]Vertical-align not working inside of td
I am trying to vertically align my div
(which is inside of a td
) to be at the top, but vertical-align: top
is not working. 我正在尝试将div
(在td
) vertical-align: top
以位于顶部,但vertical-align: top
无法正常工作。 Here is the fiddle: 这是小提琴:
http://jsfiddle.net/hreDw/1/ (I want that yellow b
to be at the top) http://jsfiddle.net/hreDw/1/ (我希望黄色b
在顶部)
How can I do this? 我怎样才能做到这一点? Also, amount of a's
inside of the second td is dynamic - so the height of the table is also dynamic. 另外,第二个td内部的a's
数量是动态的-因此表的高度也是动态的。
The
vertical-align
CSS property specifies the vertical alignment of an inline or table-cell box.vertical-align
CSS属性指定嵌入式或表格单元格框的垂直对齐方式。
Read more about vertical-align
阅读有关vertical-align
更多信息
Therefore, you have to apply the vertical-align
property to the td
element: 因此,您必须将vertical-align
属性应用于td
元素:
.first {
background-color:black;
min-height: 10px;
min-width: 10px;
vertical-align: top;
}
.first div {
background-color:yellow;
}
.second {
background-color:green;
min-height: 10px;
width: 10px;
}
The vertical-align
has to be on the td
and not the div
. vertical-align
必须在td
而不是div
。
Right now you are simply applying the vertical alignment to the div
itself, but instead you want everything in the TD
to be vertically aligned: 现在,您只是将垂直对齐方式应用于div
本身,而是希望将TD
所有内容垂直对齐:
.first {
background-color:black;
min-height: 10px;
min-width: 10px;
vertical-align: top;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.