user1318194
user1318194

Reputation:

Firefox not respecting visibility:hidden on table header

I want the header of the first column in my table to be hidden, to get this look:

table with desired look

So I am using the CSS visibility: hidden; to do so. The screenshot above is taken in Chrome, where it works perfectly. However, this happens in Firefox:

how firefox handles the same CSS

How can I make Firefox hide the header of the first column in a table?



EDIT: Here's my table CSS, as requested:

.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; }

Upvotes: 3

Views: 4120

Answers (2)

Muhammad Murad Haider
Muhammad Murad Haider

Reputation: 1467

Depends upon what you want to achieve in styling, but generally, setting relevant element's (color/background-color/border-(top n left)-color(in this case)) to 'transparent' usually works across browsers.

hope this helps someone.

Upvotes: 0

Patrick Moore
Patrick Moore

Reputation: 13354

This works for me in all major browsers:

<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>

Upvotes: 2

Related Questions