to ask a question, please see the code:
target5</span>
</div>
</body>
</html>
The goal of is to select the 2n any element with a .target class name, that is, target2, target4
if you use .target: nth-of-type (2n)
, this selector indicates this is the 2n span, of the parent element with target class , and target2 is the third span, so it is not selected.
if you use .target:nth-child (2n)
, this selector represents the 2n element of the parent element, with target class . Causes the sixth and eighth elements of the parent element, target3 and target5, to be selected, and the seventh element, target4, to be unselected.
is there any other way to use only css without moving html,?