CSS而不是()使用儿童

时间:2011-08-09 09:11:11

标签: css css-selectors

我想将属性应用于所有输入[type = text] 元素但排除某些元素。 要排除的元素没有任何类,但它们的父级是。

HTML看起来像

<tr class="filters">
    <td>
        <input type="text" name="aName">
    </td>
    <td>
        <input type="text" name="anotherName">
    </td>
        ...
</tr>

我试过这个CSS:

input[type=text]:not(tr.filters > td > input[type=text])
{
    min-width:400px;
}

但它不起作用。 是不是可以这样使用not()?

2 个答案:

答案 0 :(得分:3)

使用:not()作为CSS选择器是不可能的。 :not() pseudo-class只接受一个简单的选择器(这意味着只有一个type.class#id[attribute] {{1选择器)。 :pseudo-class和等组合不允许使用。

>的默认值为零,因此您只需使用覆盖规则并将其设置为:

+

答案 1 :(得分:0)

你为什么不使用这样的东西?

tr:not(.filters) td input[type=text]
{
    min-width:400px;
}