scss同时使用两个数组

Posted 223zzm

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了scss同时使用两个数组相关的知识,希望对你有一定的参考价值。

<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同时使用两个数组的主要内容,如果未能解决你的问题,请参考以下文章

ArrayIndexOutOfBoundsException,同时找到数组中两个连续元素之间的最大差异

在bash中同时迭代两个数组

有没有办法在保持 O(n) 的同时将两个嵌套数组相乘?

同时对两个数组进行排序

forEach 在javascript中同时循环遍历两个数组[重复]

如何同时访问两个大小不同的数组? [关闭]