単純なCSS3線形グラデーションを処理するためのこのミックスインがあります。
@mixin linear-gradient($from, $to, $dir: bottom, $dir-webkit: top, $ie-filters: false) {
background-color: $to;
background-image: -webkit-linear-gradient($dir-webkit, $from, $to);
background-image: linear-gradient(to $dir, $from, $to);
@if $ie-filters == true and $old-ie {
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{ie-hex-str($from)}', endColorstr='#{ie-hex-str($to)}');
}
}
$dir
'direction'の略です。
$ie-filters
'true'にする必要があり、/$dir
デフォルト$dir-webkit
値を変更する必要がない場合でも、それらを再宣言する必要がありますが、これは明らかにあまり乾燥しておらず、最適ではないため、次のようにする必要があります。
@include linear-gradient(#7a7a7a, #1a1a1a, bottom, top, true);
私がこれをしたいとき:
@include linear-gradient(#7a7a7a, #1a1a1a, true);
ミックスインを呼び出すときに、この方法で引数をスキップするにはどうすればよいですか?
$dir-webkit
PSまだ新しいグラデーション構文を処理していないため、Webkitの引数について疑問がある場合は( http://generatedcontent.org/post/37949105556/updateyourcss3- >新しいグラデーション構文を参照)、方向は次のようになります。標準の構文の反対になります。