奇怪的CSS格式错误

时间:2014-07-17 08:10:06

标签: html css

我有一个奇怪的CSS错误。我应该在哪里看?

我有一张桌子。在表格的第一行中,我将行的高度设置为40px。

table.categories-table tr.categories-table-row1 {
    width:100%;
    height:40px;
    inline-height:40px;
    text-align:center;
    font-weight:bold;
    padding:0px;
}

这似乎出现在检查员身上(因为我不知道为什么它会变灰)。enter image description here

然而,该行看起来比40px更高,并且在检查员的底部,我看到了这一点:

enter image description here

奇怪的是,当我刷新屏幕时,行的高度越来越小,直到达到40px。然后,随后的刷新使其保持在40px。但是,如果我关闭选项卡,打开选项卡并再次打开页面,该行高于40px。

关于我应该在哪些方面破解这个错误的想法?

3 个答案:

答案 0 :(得分:2)

您需要使用line-height:40px;

inline-height不是有效的CSS属性。

答案 1 :(得分:0)

我猜你的问题是你选择了<td>,然后将你的CSS集中在<tr>上。

所以当你这样做时:

table.categories-table tr.categories-table-row1 td {
    width:100%;
    height:40px;
    /*inline-height:40px; not valid */
    line-height: 40px;
    text-align:center;
    font-weight:bold;
    padding:0px;
}

它不应该变灰。你的td也有40px的高度。

实例:http://jsfiddle.net/bc7aJ/

答案 2 :(得分:0)

没有这样的&#34;内联高度&#34;属性。试试&#34; line-height&#34;。

table.categories-table tr.categories-table-row1 td{line-height:40px;}