Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is not () in css?

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the css: what is not (), the article is very detailed, has a certain reference value, interested friends must read it!

: not () is a negative pseudo-class selector for CSS. It is a functional pseudo-class selector that takes a simple selector (shown below) as a parameter and then matches one or more elements that are not represented by the parameter.

What can be used as a: not () parameter can be any of the following simple selectors:

1. Tag selector (e. G. pdinger span, etc.)

2. Class selection (e.g. .element, .sidebar, etc.)

3. ID selector (for example, # header)

4. Pseudo-class selector (for example: first-child,:last-of-type)

5. Attribute selector (e.g. [type= "checkbox"])

6. Universal selector (*)

However, the parameter passed to: not () cannot be a pseudo-element selector (for example:: before,:: after, etc.) or another negative pseudo-class selector.

Therefore, the following is not valid: the not () value:

/ * invalid * /

P:not (: not (.same)) {}

P:not (: not (: last-child)) {}

: not (:: first-letter) {}

A:not (:: after) {}

As you can see from the example above, not () cannot be nested, for example: not (: not (..)). It cannot be nested in: matches () pseudo class, for example: selector (: matches (: not (..)).

As mentioned earlier, the: not () selector will match elements in its parameters that are not represented by the selector. So, this css statement::

Li:not (.new) {

/ * all style list items, except those with new classes * /

}

All list items except those with .new class names are selected.

: not () selection can be linked to more: not () selection. For example, the following will match all s#featured of article except ID, and then filter out articles with class names. tutorial:

Article:not (# featured): not (.tutorial) {

/ * formatting articles * /

}

: not () can also be linked to other pseudo classes and pseudo elements. For example, the following uses .old to add "new!" using:: after pseudo element Word to list items without a class name:

Li:not (.old):: after {

Content: "New!"

Color:deepPink

}

Description:

: not () pseudo-class selection allows you to write useless choices. For example: not (*), which simply does not mean that any element will never have any style applied.

The above is all the contents of the article "what is not () in css?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report