applying css for only parent but not to children

前端 未结 4 1722
闹比i
闹比i 2020-12-05 09:58

I have an unordered list like this:

  • list1
    • Sub list1<
4条回答
  •  日久生厌
    2020-12-05 10:06

    Use the direct descendant operator > for that:

    .list > ul > li { ... }
    

    The > operator selects only elements that are direct children of the element(s) before it.

    Note however, anything inside that list item will of course have the background of the list item despite not having any background color directly assigned to it.

提交回复
热议问题