Firefox不尊重可见性:隐藏在表头上

时间:2013-01-27 02:16:34

标签: html css firefox html-table

我希望隐藏表格中第一列的标题,以便看看:

table with desired look

所以我使用CSS visibility: hidden;这样做。上面的屏幕截图是在Chrome中完美呈现的。但是,这种情况发生在Firefox中:

how firefox handles the same CSS

如何让Firefox隐藏表格中第一列的标题?



编辑:这是我的表格CSS,按要求:

.styledtable{
    width:100%;
    table-layout:fixed; /*each column same width, unless width explicitly specified*/
    border:1px solid black;
    border-collapse:collapse;
}
.styledtable td, .styledtable th{
    border:1px solid black;
    padding:3px;
}

.styledtable th{ background:#cfcfcf; }
.styledtable td{ background:white; }

/* in a table with the first columnn empty (ie. with actions in the column below it),
 * make the first column take up space, but not actually appear.
 * Usage: <th style="width:40%;" class="firstcol">&nbsp;</th>
 */
.firstcol{
    visibility:hidden;
}

/*every second row different color, if the table itself doesn't have the class "no-odd-row-highlight"*/
.styledtable:not(.no-odd-row-highlight) tr:nth-child(odd) td{ background:#eeeeee; }

2 个答案:

答案 0 :(得分:2)

这适用于所有主流浏览器:

<style type="text/css">
table {
    border: none;
    padding: 0;
    border-spacing: 0;
    border-collapse: collapse;
}

table th,
table td {
    margin: 0;
    background: #fff;
    border: 1px solid #000;
    padding: 0;
}

table th.hidden {
    border: none;
    visibility: hidden;
}
</style>

<table>
<tr>
<th class="hidden"></th>
<th>ID</th>
<th>Something</th>
</tr>
<tr>
<td>Options</td>
<td>1</td>
<td>---</td>
</tr>
</table>

答案 1 :(得分:0)

取决于你想要在造型中实现什么,但一般来说,将相关元素(颜色/背景颜色/边框 - (左上角) - 颜色(在这种情况下))设置为&#39;透明&#39;通常适用于浏览器。

希望这有助于某人。