首页 > 编程语言 > 详细

scss同时使用两个数组

时间:2019-08-11 17:18:48      阅读:110      评论:0      收藏:0      [点我收藏+]
<div class="content">
   <div v-for="(item,index) in 5" :key="index" :class="`box box${index}`"></div>
</div>
<style lang=‘scss‘ scoped>
.content{
  position: relative;
}
.box{
  position: absolute;
  width: 50px;
  height: 50px;
}
$color: red,green,blue,yellow,pink;
$top: ‘0px‘ ‘50px‘ ‘100px‘ ‘150px‘ ‘200px‘;
$left: ‘0px‘,‘50px‘,‘100px‘,‘150px‘,‘200px‘;
//    遍历一个数组
@each $c in $color{
  $i:index($color,$c);
  .box#{$i - 1}{
    background: nth($color,$i);;
  }
}
//    同时使用两个数组
@for $i from 1 to length($top) + 1 {
  .box#{$i - 1}{
    top: #{nth($top, $i)};
    left: #{nth($left, $i)};
  }
}
</style>

 

scss同时使用两个数组

原文:https://www.cnblogs.com/223zzm/p/11335310.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!