About CSS3:nth-child() selector_html/css_WEB-ITnose
Jun 24, 2016 am 11:57 AM 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;}
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");

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

What is the identifier of the id selector in css

How to implement lace borders in css3

Use the :nth-child(n+3) pseudo-class selector to select the style of child elements whose position is greater than or equal to 3

Learn new CSS features: Directional clipping overflow:clip

From beginner to proficient: Master the skills of using is and where selectors

What to do if the javascript selector fails
