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

How css selects only even rows

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

Share

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

This article mainly explains "how to select even rows for css". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how css chooses only even rows".

In css, you can use the pseudo-class selector ": nth-child ()" to select even rows of regular elements such as a table or li. The syntax "element: nth-child (2n) {style}" or "element: nth-child (even) {style}".

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

In css, you can use the pseudo-class selector ": nth-child ()" to select even rows. The css3 pseudo-class selector: nth-child () allows you to select even rows of regular elements such as tables or li.

The nth-child (n) selector matches the nth child element of the parent element, and there is no restriction on the element type. N can be a number, a keyword, or a formula.

Even rows can be selected when n is the keyword "even" or the formula "2n".

Select the syntax for even-numbered lines:

Element: nth-child (2n) {style} element: nth-child (even) {style}

Example:

P:nth-child (2n) {background:#ff0000;} li:nth-child (even) {background:# AFEEEE;}

This is the first paragraph.

This is the second paragraph.

This is the third paragraph.

This is the fourth paragraph.

Item 1, item 2, item 3, item 4.

Effect picture:

At this point, I believe you have a deeper understanding of "css how to choose only even rows". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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