scss #sass @each

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了scss #sass @each相关的知识,希望对你有一定的参考价值。


// https://github.com/sass/node-sass/issues/263#issuecomment-38404669

$foo: (puma, black, default),
      (sea-slug, blue, pointer),
      (egret, white, move);

@each $val in $foo {
  $animal: nth($val, 1);
  $color: nth($val, 2);
  $cursor: nth($val, 3);

  .#{$animal}-icon {
    background-image: url('/images/#{$animal}.png');
    border: 2px solid $color;
    cursor: $cursor;
  }
}
.section-news.page-news {

  // Add a news block for each year
  @each $newsYear in 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 {

    &.page-news-#{$newsYear} .news-menu.block {

      h3 a.anchor-#{$newsYear} { @include anchor-hover; }

      ul li.views-row.year-#{$newsYear} a { background-color: #edc265; }
    }
  }
}

以上是关于scss #sass @each的主要内容,如果未能解决你的问题,请参考以下文章

scss #sass @each

Scss 基本使用 ( @extend @mixin@import@if@for@while@each )

sass @each 奇怪的行为

SCSS / SASS:如何在每个循环中创建变量

SCSS 插值无法为宽度分配百分比

sass和scss区别?