看一看以下两个图像:CSS表单元格大小 - conterintuitive行为
启用或禁用表单元格属性丢弃一些宽度和高度的信息。其实我已经将它们禁用了浏览器,但重新启用它们不会改变任何内容。
使用display:table-cell
是使用vertical-align
将容器中的某些文本居中的唯一方法。
但随后变得很难与黄色div元素的宽度玩。为什么? (也不知..如果某些属性时,一些人被启用浏览器可以用不同的颜色标记它们或他们三振。还是会有一些缺点一些元素得到uneffective?)
.grey-footer-background {
background-color: #a8a7a5;
height: 70px;
border-bottom: 1px black solid;
padding-top: 8px;
display: table;
height: 100px;
width: 100%;
table-layout: fixed;
}
.gold_button {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
font-weight: bold;
text-align: center;
border-right: solid 1px #262626;
width: 80%;
height: 60px;
vertical-align: middle !important;
border: 1px solid black;
margin: 0 auto;
display: table-cell;
}
<div class="grey-footer-background">
<div class="gold_button"><span>Email</span>
</div>
</div>
这是一个非常好的解决办法..也许是最好的一个,但它需要知道父元素的高度..对于我W3C应该添加另一个垂直对齐来改变元素的对齐方式,如表格单元格的方式。但是+1 – Revious 2014-10-02 11:23:34