Home >Web Front-end >Front-end Q&A >What is the usage of odd and even in css3
In CSS3, odd and even are used as keywords in pseudo-class selectors to select specified elements. odd represents odd elements and even represents even elements; odd and even are often used with ":nth-child(n )" selector, the syntax is "element: selector (odd or even) {css style code}".
The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.
odd represents an odd number and even represents an even number.
odd and even are often used to select specified elements in pseudo-class selectors.
The example is as follows:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>菜鸟教程(runoob.com)</title> <style> p:nth-child(odd) { background:#ff0000; } p:nth-child(even) { background:#0000ff; } </style> </head> <body> <h1>This is a heading</h1> <p>The first paragraph.</p> <p>The second paragraph.</p> <p>The third paragraph.</p> <p><b>注意:</b> Internet Explorer 8 and以及更早版本的浏览器 :nth-child()选择器.</p> </body> </html>
Output result:
(Learning video sharing: css video tutorial)
The above is the detailed content of What is the usage of odd and even in css3. For more information, please follow other related articles on the PHP Chinese website!