i try access previous item in list using sass can add variable $itemwidthincrement onto previous items value hence having increment of 3px each item:
$totalitems: 12; $itemwidthincrement: 3px; $itemmarginincrement: 1px; @for $i 1 through $totalitems { .item-:nth-child(#{$i}) { float: if($i % 2 == 0, left, right); width:/*get previous item here*/ + $itemwidthincrement; } }
is doable sass or not approaching in correct manner?
try - keep $currentwidth
variable , increment necessary:
$totalitems: 12; $itemwidthincrement: 3px; $itemmarginincrement: 1px; $currentwidth: 1px; @for $i 1 through $totalitems { .item-:nth-child(#{$i}) { float: if($i % 2 == 0, left, right); width: $currentwidth; } $currentwidth: $currentwidth + $itemwidthincrement; }
Comments
Post a Comment