SCSS 使用@each 方法循环遍历数组颜色并给li赋值

$list-bg:red,orange,blue,skyblue;
ul{
    >li{
      height: 30px;
      @each $c in $list-bg{
             $i:index($list-bg,$c);
             &:nth-child(#{$i+1}){//+1是除了第一个以外的li 
                background: nth($list-bg,$i);
             }
        }
    }
}

  

posted @ 2018-06-28 11:50  飞尽堂前燕  阅读(3940)  评论(0编辑  收藏  举报