About CSS3:nth-child() selector_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:57:24
Original
973 people have browsed it

A page with many small squares. The class of the big square is big and the class of the small square is small. Use the css3 selector to write this:

.small:nth-child(even){margin-right:0;}
Copy after login


Set the even-numbered small The margin-right of the square is 0, but the margin-right of the third small square is equal to 0. What's going on?

demo: http://guusoft.com/test/


Reply to discussion (solution)

Through the guidance of other netizens , understand that selecting the odd-numbered or even-numbered child element from the parent element does not specify a certain type (.small), but all child elements are counted.
So the final solution is:

$(".small:odd").addClass("last");
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template