0
使用跨瀏覽器漸變@mixin我一直追着我的尾巴超過兩個小時。SASS漸變@mixin讓我瘋狂
我想要得到這樣的結果:
-moz-linear-gradient(left, #fff 0%, #000 100%);
從提供的默認參數:
@mixin gradient($type:linear, $gradient:(#fff 0%, #000 100%), $shape:vertical, $repeat:false){
background:nth(nth($gradient, 1), 1);
$background:null;
$vendors:null;
@if $shape == vertical {
$vendors: (
mozilla: (-moz-, top),
webkit: (-webkit-, top),
opera: (-o-, top),
standard: ("", to bottom)
);
}@else if $shape == horizontal {
$vendors: (
mozilla: (-moz-, left),
webkit: (-webkit-, right),
opera: (-o-, right),
standard: ("", to right)
);
}@else{
$vendors: (
mozilla: (-moz-, $shape),
webkit: (-webkit-, $shape),
opera: (-o-, $shape),
standard: ("", to $shape)
);
}
@if $repeat == true{
$background:repeating-+$type+-gradient;
}@else if $repeat == false {
$background:$type+-gradient;
}
@if $type == linear {
@each $vendor in $vendors {
background:[?????];
}
}@elseif $type == radial {
@each $vendor in $vendors {
background:[?????];
}
}
}
我會很感激在這一個幫助之前,我砸我的筆記本電腦與我頭!
就個人而言,我只想寫混入然後運行autoprefixer並讓它擔心前綴。只需做這樣的事情「=顏色($ color1,$ color2,$ color3) \t背景:線性漸變($ color1,$ color2,$ color3)」並將其餘的需求作爲變量添加。然後在使用mixin時插入變量 – Brad