我有以下SCSS混入爲此我可能寫太多冗餘的東西:如何簡化這個SCSS邊界半徑Mixin? - 薩斯初級
@mixin radius($topleft, $topright: $topleft, $bottomright: $topleft, $bottomleft: $topleft) {
-moz-border-radius-topleft: $topleft;
-moz-border-radius-topright: $topright;
-moz-border-radius-bottomright: $bottomright;
-moz-border-radius-bottomleft: $bottomleft;
-webkit-border-radius: $topleft $topright $bottomright $bottomleft;
border-radius: $topleft $topright $bottomright $bottomleft;
}
注意,這個論點可以採取單一的價值,適用於所有的邊,或全部4定製。
'$ bottomleft'變量應該設置爲'$ topright'作爲默認值,以防您使用速記聲明並且只傳遞兩個變量。因爲'border-radius:0 3px'相當於'border-radius:0 3px 0 3px',而不是'border-radius:0 3px 0 0'。 – inko9nito