下图是使用同一浏览器(Chrome 25)对同一页面的渲染。唯一的区别是一个页面有一个 DOCTYPE(因此在标准模式中)而一个没有(因此在 Quirks 中)
怪癖:
标准:
两个细胞都有vertical-align: middle
,两个图像都是display: inline-block
。
Vertical-align 在 Quirks 中有效,但在 Standard 中无效,为什么?
HTML
<table class="oppres" id="oppscore4">
<tbody>
<tr id="oppscore4-main">
<td><img src="images/gold.png"></td>
<td></td>
<td>0</td>
</tr>
<tr></tr>
<tr id="oppscore4-total">
<td></td>
<td>=</td>
<td>0</td>
</tr>
</tbody>
</table>
CSS
table.oppres{
height: 120px;
}
table[id^=oppscore]{
width: 80px;
font-size: 17px;
line-height: 1;
}
table[id^=oppscore] tr{height: 1em;}
table[id^=oppscore] img{height: 0.9em;}
table[id^=oppscore] tr:nth-last-child(2){height: auto;}
table[id^=oppscore] td:first-child{text-align: right;}
足以重现该问题的代码。