Css :not() selector not supporting complex selecto

2019-05-01 23:30发布

问题:

With CSS3 both :not() selector as well as attribute contains selector are available, but while mixing the both there comes the problem, it is not working.

HTML:

<input type='text'/>
<input type='text' id="dasd_Date_asd"/>

CSS:

input[type='text']:not(input[id*='Date']) {
    display:none;
}

DEMO

Can anyone tell what is going on wrong here?

Note: There is no privilege given to us for changing the markup.

回答1:

You can't use two selectors in not:

input[type='text']:not([id*='Date']) {
  display: none;
}
<input type='text' />
<input type='text' id="dasd_Date_asd" />

Selectors level 3 does not allow anything more than a single simple selector within a :not() pseudo-class.



回答2:

You should first select input type and then cutt off the input with type id that has value "Date". your were again providing input as a selector in :not()

try this.

     input[type='text']:not([id*=Date]) {
        display:none;
    }
<input type='text'/>
<input type='text' id="dasd_Date_asd"/>