Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How does css select parity row elements

Shulou Source: shulou.com Published: 2022-05-31 12:40:28 10月03日 Update

This article mainly introduces "how css chooses parity row elements". In daily operation, I believe many people have doubts about how css chooses parity row elements. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "how css chooses parity row elements". Next, please follow the editor to study!

In css, you can use the ": nth-child (n)" selector to perform parity matching and select parity row elements; the parameter n of the selector can be a number, keyword, or formula, and set n to "Odd" or "even" keyword to match child elements whose subscript is odd or even.

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

In css, the: nth-child (n) selector matches the Nth child element that belongs to its parent element, regardless of element type.

N can be a number, keyword, or formula.

Parity matching, select parity row elements

: nth-child (odd) and: nth-child (even) match elements with odd and even serial numbers, respectively.

Odd and even are keywords that can be used to match child elements where the subscript is odd or even (the subscript of the first child element is 1).

Example:

P:nth-child (odd) {background:#ff0000;} p:nth-child (even) {background:#0000ff;}

The first paragraph.

The second paragraph.

The third paragraph.

The fourth paragraph.

Effect picture:

Explanation: the result of odd number (odd) is the same as that of (2n+1), and that of even number (even) is the same as that of (2n+0) and (2n).

At this point, the study on "how to select odd and even row elements for css" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Element selection parity even key keyword odd paragraph learning subscript size formula number more result help practical next three parameters Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS vpn Linux Microsoft Shulou Technology