Houman
Houman

Reputation: 66320

Exclude the formatting of this child from its parent

I have a CSS like below to create a certain background colour when hovering over the table.

.cb_table-hover tbody tr:hover td ,
.cb_table-hover tbody tr:hover th {
  background-color: #cfe2e8;  
}

Within a <td> I have a <div>, which I would like to exclude from this hover colour madness.

<td>
 <div class="override_td">
    {% include '_test_edit.html' %}
 </div>
</td>

So I came up with an negation for the initial hover css.

.cb_table-hover tbody tr:hover td:not(.override_td) ,
.cb_table-hover tbody tr:hover th:not(.override_td) {
  background-color: #cfe2e8;  
}

But it seems I failed already miserably because my Aptana Studio shouts that

The negation pseudo-class, :not(X), is a functional notation taking a simple selector (excluding the negation pseudo-class itself) as an argument. It represents an element that is not represented by its argument. Negations may not be nested; :not(:not(...)) is invalid. Note also that since pseudo-elements are not simple selectors, they are not a valid argument to :not().

Example The following selector matches all button elements in an HTML document that are not disabled. button:not([DISABLED]) The following selector represents all but FOO elements. *:not(FOO) The following group of selectors represents all HTML elements except links. html|*:not(:link):not(:visited)

So I am confused why it doesn't like my selector?

Upvotes: 0

Views: 391

Answers (1)

apsillers
apsillers

Reputation: 115910

Your selector looks well-formed (and follows the rules laid out in the Aptana warning message), and it works correctly, according to this fiddle. You haven't mentioned an actual failure (only a complaint from Aptana), so I assume it will work just fine.

The reason for Aptana's complaint could be that it doesn't scan for invalid :not very closely. It's possible that simply because your selector string contains two :not pseudoclasses, Aptana assumes they are invalid, even though they are separated by a comma.

Upvotes: 1

Related Questions