Home > Article > Web Front-end > How to not select the last element in css
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.
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:
Normally choose this All will be selected
Use last-child to select the last one
Add not to reverse the selection
(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!