在scss中一周连续几天运行七次

时间:2019-03-18 09:05:09

标签: css sass

我的天数可变:

$days: M T W T F S S;

和静态CSS为:

.bp3-control.bp3-checkbox input ~ .bp3-control-indicator::before {
background-image: unset;
content: "M";
padding: 7px 13px;
}

我想在星期一至星期天的不同复选框中依次设置内容。

预期输出:

enter image description here

2 个答案:

答案 0 :(得分:2)

$list: M T W T F S S;

  @each $day in $list{
    .bp3-control.bp3-checkbox input ~ .bp3-control-indicator::before {
      background-image: unset;
      content: "#{$day}";
      padding: 7px 13px;
    }
}

希望这对您有帮助

答案 1 :(得分:1)

$days: (1 "M") (2 "T") (3 "W") (4 "T") (5 "F") (6 "S") (7 "S");


@each $i in $days {
    .bp3-control.bp3-checkbox:nth-child(#{nth($i, 1)}) input ~ .bp3-control-indicator::before {
        content: "#{nth($i,2)}";
    }
}

结帐https://jsfiddle.net/moorthyrweb/3L1x5tva/