为什么要在外部添加任何元素table
?只需使用隐藏单元格来包含您想要显示的图像/元素和样式以响应:hover
parent tr
,给定标记:
<table>
<thead>
<tr>
<th></th>
<th>Column 'one'</th>
<th>Column 'two'</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>row one</td>
<td>row one</td>
</tr>
<tr>
<td></td>
<td>row two</td>
<td>row two</td>
</tr>
</tbody>
</table>
和CSS:
tr th:first-child,
tr td:first-child {
visibility: hidden;
border: 0 none transparent; /* hide the borders */
width: 1em; /* define the width, to avoid the visible content */
} /* causing page-jumps */
tr th:first-child + th,
tr td:first-child + td {
border-left: 2px solid #000; /* style the cell *after* the first-child */
} /* with a border to 'fake' the look of the */
/* new content being appended outside */
td, th {
visibility: visible;
border: 1px solid #000; /* show borders to continue the illusion */
height: 2em; /* or whatever... */
line-height: 2em;
}
这种方法似乎有效(我认为也应该在 IE 中有效): JS Fiddle demo,