/ / Ako znížiť tento css kód [duplikát] - css, sass

Ako znížiť tento css kód [duplicitné] - css, sass

Ja som pomocou tohto css kód pre môj projekt a teraz som plánovanie presunúť všetky tieto do súboru Sass som don "t vedieť, ako znížiť tento kód Som nový sass :( Existuje nejaký spôsob, ako znížiť nasledujúci kód css.

.push-bottom-0 {
padding-bottom: 0px;
}
.push-bottom-3 {
padding-bottom: 3px;
}
.push-bottom-5 {
padding-bottom: 5px;
}
.push-bottom-10 {
padding-bottom: 10px;
}
.push-bottom-13 {
padding-bottom: 10px;
}
.push-bottom-20 {
padding-bottom: 20px;
}
.push-bottom-30 {
padding-bottom: 30px;
}
.push-bottom-40 {
padding-bottom: 40px;
}
.push-bottom-50 {
padding-bottom: 50px;
}
.push-bottom-60 {
padding-bottom: 60px;
}
.push-bottom-70 {
padding-bottom: 70px;
}
.push-bottom-80 {
padding-bottom: 80px;
}
.push-bottom-90 {
padding-bottom: 90px;
}
.push-bottom-100 {
padding-bottom: 100px;
}

odpovede:

2 pre odpoveď č. 1

Môžeš použiť každý slučky.

SASS Príklad

@each $i in 0 3 5 10 13 20 30 40 50 60 70 80 90 100
.push-bottom-#{$i}
padding-bottom: #{$i}px

Príklad SCSS:

@each $i in 0, 3, 5, 10, 13, 20, 30, 40, 50, 60, 70, 80, 90, 100 {
.push-bottom-#{$i} {
padding-bottom: #{$i}px;
}
}

1 pre odpoveď č. 2

Môžete vyskúšať slučky Sass

@list 0 3 5 10 13 20 30 40 50 60 70 80 90 100

@each $number in $list
.push-bottom-#{$number} {
padding-bottom: $number;
}

http://thesassway.com/intermediate/if-for-each-while