我在网格表单中以<table>显示结果。有一个ID列。无论如何,通过HTML或CSS,我可以隐藏第一列吗?

有帮助吗?

解决方案

添加<!>“; display:none; <!> quot;样式到与列对应的<col>元素。如果您想稍后显示该列,请在<=>中添加一个id。

<table>
    <col id="x" style="display:none" />
    <col />
    <col />
    <tr>
        <td>1</td>
        <td>2</td>
        <td>3</td>
    </tr>
</table>

<script>
    function showColumn() {
        document.getElementById("x").style.display = "";
    }
</script>

其他提示

<colgroup>看起来很有前途,但实际上它不允许过多的CSS支持 - 许多CSS attrubutes根本不适用于colgroup: http://www.w3schools.com/tags/tag_colgroup.asp
另一个选项是高级CSS选择器,例如+:nth-child,但旧浏览器不支持它们 最好的办法是在该列中添加一个类,或者使用JavaScript。

tr > td:first-child { 
  display:none;
}

你可以应用css规则:

display: none;

CSS显示属性

您可能不会首先将该列添加到HTML中。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top