nth-child() or first-child? how to select first AND second child in one

前端 未结 5 973
再見小時候
再見小時候 2020-12-24 13:25

I\'d like to select the first two list items in an unordered list. I can select the first item thus:

ul li:nth-child(1) a {
    background: none repeat scrol         


        
5条回答
  •  鱼传尺愫
    2020-12-24 14:04

    .trJobStatus ul{
        width: 500px;
      height:500px;
        float: left;
      }
    .trJobStatus ul li{
       width: 50px;
      height:50px;
      border: solid 1px #ffffd;
      list-style:none;
      display: inline-block;
      text-align: center;
      line-height:50px;
      font-size:25px;
      }
    
    .trJobStatus ul li:nth-child(1),
    .trJobStatus ul li:nth-child(5){
      color:red;
      }
     
      
    • 1
    • 2
    • 3
    • 4
    • 5

    .trJobStatus ul li:nth-child(1), .trJobStatus ul li:nth-child(2) { color: #fff; background-color:#ffffd; }

提交回复
热议问题