CSS select second level elements

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

How to remove background on a second level li elements ?

  • Test
3条回答
  •  别那么骄傲
    2021-01-18 12:04

    IT happens because you ars setting the background to the entire

  • , and the second level is inside to the first , your second level has a transparent background and that's the reason because you see red (is the inmediately background set). You have 2 options:

    1. set the background to the elements
    2. set a background matching to the original background

    I recommend set the background to the elements like this:

    ul.navi > li  {
        line-height: 36px;
        border-radius: 8px;
        margin-bottom: 10px;
    }
    ul.navi > li > a {
     background-color: red;
        }
    

    fiddle : http://jsfiddle.net/zhrgyLrf/2/

提交回复
热议问题