CSS select second level elements

后端 未结 3 861
天命终不由人
天命终不由人 2021-01-18 11:51

How to remove background on a second level li elements ?

  • Test
3条回答
  •  渐次进展
    2021-01-18 12:26

    Why not just set the background on the direct a child elements?

    Updated Example

    ul.navi > li > a {
        background-color: red;
    }
    

    The reason background: none wasn't working is because you are setting the background on the entire parent, li element. Thus, even though the children don't have a background, the parent's background is still shown because it encompasses the children. As an alternative, you would have to set the children's background to #fff. In doing so, you would unfortunately lose your transparency, though.

提交回复
热议问题