[英]Text Will NOT Vertically Align Inside Div No Matter What
inline-block, table-cell, line-height, etc. none of it affects the alignment of my text... 内联块,表格单元格,行高等等都不会影响文本的对齐...
Demo: http://colechrzan.com/tv_rewrite 演示: http : //colechrzan.com/tv_rewrite
HTML: HTML:
<div class="toolbar">
<form>
<div class="search">
<input type="text">
<div class="remove">Clear</div>
</div>
</form>
</div>
CSS: CSS:
.remove {
background: #fff;
display: inline-block;
color: #1E1E20;
position: absolute;
top: 50%;
margin-top: -16px;
left: calc(50% + 15px);
height: 32px;
padding: 0 4px;
line-height: 32px;
text-align: center;
vertical-align: middle;
font: 18px 'Open Sans';
}
I've tested countless solutions and nothing matters; 我已经测试过无数的解决方案而且无关紧要; the alignment always remains as it looks now. 对齐始终保持现状。
line-height: 32px
是这里的关键,但它被下面的字体声明覆盖,因此您可以将其更改为:
font: 18px/32px 'Open Sans';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.