Html 某些表中每个 tr 的第一个 td 的 CSS

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20067347/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 22:10:03  来源:igfitidea点击:

CSS for first td of each tr in certain table

htmlcss

提问by Merin Nakarmi

I have table with id "student". e.g.

我有一个 ID 为“学生”的表。例如

 <table id="student">
    <tr>
        <td>Role</td>
        <td>Merin</td>
        <td>Nakarmi</td>
    </tr>
    <tr>
        <td>Role</td>
        <td>Tchelen</td>
        <td>Lilian</td>
    </tr>
    <tr>
        <td>Role</td>
        <td>Suraj</td>
        <td>Shrestha</td>
    </tr>
</table>

For each row in this table, the first <td>has value Role and I want to hide this first <td>for every row. I tried option like

对于此表中的每一行,第一个<td>具有值 Role,我想<td>为每一行先隐藏它。我试过这样的选择

#student > tr > td:first-child
{ 
    width: 0px; important;
}

But unfortunately did not work.

但不幸的是没有奏效。

Please help

请帮忙

回答by Nitesh

Use the below.

使用下面的。

table#student tr td:first-child{display:none;}

WORKING DEMO

工作演示

回答by Code L?ver

Your this code is not correct:

您的此代码不正确:

{ width: 0px; important; }

this should be:

这应该是:

#student > tr > td:first-child{ 
  width: 0px !important; 
}

before importantproperty you are using semicolon which is not correct.

important属性之前,您使用的是不正确的分号。

回答by Venu immadi

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