I could not find good references about how to use mixins from bootstrap-sass. I’m trying to add gradient effect to my background color, and I want to learn how to use the built-in gradient function from the mixin.
// Gradients
@mixin gradient-horizontal($startColor: #555, $endColor: #333) {
background-color: $endColor;
background-image: -moz-linear-gradient(left, $startColor, $endColor); // FF 3.6+
background-image: -webkit-gradient(linear, 0 0, 100% 0, from($startColor), to($endColor)); // Safari 4+, Chrome 2+
background-image: -webkit-linear-gradient(left, $startColor, $endColor); // Safari 5.1+, Chrome 10+
background-image: -o-linear-gradient(left, $startColor, $endColor); // Opera 11.10
background-image: linear-gradient(to right, $startColor, $endColor); // Standard, IE10
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{ie-hex- str($startColor)}', endColorstr='#{ie-hex-str($endColor)}', GradientType=1); // IE9 and down
}
In application.css.scss file, I tried
body {
padding-right: 50px;
padding-left: 50px;
gradient-vertical($startcolor: $white, $endcolor: #08C);
}
But did not work. I appreciate your help.
Try this:
The mixin arguments are usually optional (unless you omit some or declare them out of order), but there’s nothing wrong with using them like you have (
$startcolor: $white, etc). The only thing you are missing is the@include. Also make sure you have@import "bootstrap";at the top ofapplication.css.scss.You can refer to SASS Reference for more info.