How to use nth-of-type to select nested children

前端 未结 2 395
独厮守ぢ
独厮守ぢ 2021-01-04 01:50

I am trying to style odd and even headers that are associated with content. They are inside several DIVs, and I am unable to get nth-child or nth-of-type to work- only the

2条回答
  •  离开以前
    2021-01-04 02:02

    Try this

    .content div.post:nth-of-type(odd) a{color: #444;}
    .content div.post:nth-of-type(even) a{color: #ccc;}
    

    The a element of odd and even divs with post class. Not quite sure if that's what you need. A working example: http://jsfiddle.net/a4j7z/

提交回复
热议问题