是否可以在不使用空元素的情况下将一个颜色框浮动到表格行的左侧?
我想<span></span>
首先摆脱,<td>
如果可能的话只使用纯CSS。
它应该看起来像这样
这是我目前拥有的:
<table border="1">
<tr>
<td><span></span>float a box of any color to the left of this row</td>
</tr>
<tr>
<td>it should be the same heieght as the row</td>
</tr>
<tr>
<td>and 15 pixels wide</td>
</tr>
</table>
table {
margin: 10px 10px 10px 25px;
}
table td {
position: relative;
padding: 5px;
}
/* can i achieve the same effect without having
to rely on a <span> element? */
table td span {
position: absolute;
top: 0;
left: -20px;
width: 15px;
height: 100%;
background-color: green;
}