1
我想弄清楚如何聲明和訪問與SASS每個循環上的嵌套列表。我想在第一個循環內使用第二級循環?每個迴路上的SASS訪問嵌套多維列表
這裏是我的示例代碼:
$chap1-blocks: (5
(1, -70, 30),
(2, -130, 80),
(3, 10, -30),
(4, -90, 50)
),
(7
(1, -70, 30),
(2, -130, 80),
(3, 10, -30),
(4, -90, 50)
),
(10
(1, -70, 30),
(2, -130, 80),
(3, 10, -30),
(4, -90, 50)
);
@each $chap1-block in $chap1-blocks {
$section: nth($chap1-block, 1); //5
$row: nth($chap1-block, ??); //1
$top: nth($chap1-block, ??); //-70
$bottom: nth($chap1-block, ??); //30
.section-#{$section} {
.row-#{$row} {
margin: #{$top}px 0 #{$bottom}px;
}
}
}
期望中的第一組輸出:
.section-5 .row-1 {
margin: -70px 0 30px;
}
.section-5 .row-2 {
margin: -130px 0 80px;
}
.section-5 .row-3 {
margin: 10px 0 -30px;
}
.section-5 .row-4 {
margin: -90px 0 50px;
}