Home  >  Article  >  Web Front-end  >  How to not select the last element in css

How to not select the last element in css

青灯夜游
青灯夜游Original
2021-07-21 17:23:4318717browse

In CSS, you can use the ":last-child" and ":not()" selectors to not select the last element, the syntax format is "element:not(:last-child)". The last-child selector can match the last child element, while not() can match every element that is not the specified element/selector.

How to not select the last element in css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

In CSS, you can use the ":last-child" and ":not()" selectors to not select the last element. In other words: you can select all elements except the last element.

  • :last-child selector matches every element that is the last child element of its parent element.

  • :not(selector) The selector matches every element that is not the specified element/selector.

Example:

Create html part:

How to not select the last element in css

Normally choose this All will be selected

How to not select the last element in css

Use last-child to select the last one

How to not select the last element in css

Add not to reverse the selection

How to not select the last element in css

(Learning video sharing: css video tutorial)

The above is the detailed content of How to not select the last element in css. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to inline css stylesNext article:How to inline css styles