CSS global :nth-of-type selector (:nth-of-class)

后端 未结 2 1867
梦毁少年i
梦毁少年i 2021-01-16 05:36

What CSS selector can be used to select all odd elements inside a parent, but which are not necessarily siblings?

2条回答
  •  天涯浪人
    2021-01-16 05:58

    While it uses JavaScript, you could style the odd element without altering your markup:

    $('.parent .element:odd').css('font-weight', 'bold');
    

    ​ http://jsfiddle.net/ansonhoyt/MfxYF/

提交回复
热议问题