[英]Vertical align text with floating inside Containing Div
There's a piece of html:- 有一段html:-
<div class="field-display">
the text here
<a class="delete">x</a>
</div>
The anchor element is button which has float: right;
锚元素是具有
float: right;
按钮float: right;
CSS property. CSS属性。 The CSS for the div is:-
div的CSS是:-
.field-display {
height: 25px;
padding: 2px 15px 2px 10px;
vertical-align: middle;
}
But vertical-align: middle;
但
vertical-align: middle;
is not working. 不管用。 Any Idea how to align text in middle of the div?
任何想法如何在div的中间对齐文本?
You can add display: table-cell;
您可以添加
display: table-cell;
to your div. 给你的div
.field-display {
width: 100px;
height: 100px;
border: 1px solid black;
padding: 2px 15px 2px 10px;
vertical-align: middle;
display: table-cell;
}
Side Note : display: table-cell;
旁注:
display: table-cell;
is supported by IE8 and above..! 受IE8及更高版本的支持。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.