我有一个由网页生成的表格元素,我需要将显示设置为无。但是,table元素没有id或与之关联的类。这就是我剩下的:
<table role="presentation" data-name="personal">
有没有人对如何隐藏这个有任何想法?我在上周试过了,但这不符合我的技能。
我还要补充一点,我在页面上还有其他几个表。唯一可区分的特征是'data-name =“personal”'似乎不同,因此我可以定位数据名称,但不确定如何实现这一点。
试试这个:
table[data-name="personal"] {
display:none;
}
阅读有关CSS Attribute Selector的更多详情。
您的案例涉及[attribute =“value”]选择器,因此您可以执行以下操作:
使用数据名称属性:
table[data-name="personal"] {
display:none;
}
或使用角色属性:
table[role="presentation"] {
display:none;
}
下面是您可以尝试的一些示例。使用display:none存放属性。
[data-value] {
/* Attribute exists */
}
[data-value="foo"] {
/* Attribute has this exact value */
}
[data-value*="foo"] {
/* Attribute value contains this value somewhere in it */
}
[data-value~="foo"] {
/* Attribute has this value in a space-separated list somewhere */
}
[data-value^="foo"] {
/* Attribute value starts with this */
}
[data-value|="foo"] {
/* Attribute value starts with this in a dash-separated list */
}
[data-value$="foo"] {
/* Attribute value ends with this */
}