How do I select the first adjacent sibling?

前端 未结 8 2272
北海茫月
北海茫月 2020-12-30 19:38

I have an HTML list like so:

  • Heading 1
8条回答
  •  情话喂你
    2020-12-30 20:34

    There are a few ways to hide only the "Heading 1" only:

    ul li:first-child {display:none;}

    Alternatively:

    li.parent{ display: none; }
    li.parent + li.parent { display: list-item; }
    

    Also,

  • Child of Heading 2
  • is not a child of
  • Heading 2
  • . It is a sibling.

提交回复
热议问题