applying css for only parent but not to children

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

I have an unordered list like this:

  • list1
    • Sub list1<
4条回答
  •  执笔经年
    2020-12-05 10:24

    The only way of doing this is like:

    .List > ul > li { background-color: #ccc; }
    

    If you want to apply only the bgcolor to the ul simply do:

    .List > ul { background-color: #ccc; }
    

    :)

提交回复
热议问题