_background-image.scss 1.3 KB
Newer Older
1 2 3 4 5
//************************************************************************//
// Background-image property for adding multiple background images with
// gradients, or for stringing multiple gradients together.
//************************************************************************//

6
@mixin background-image($images...) {
7 8 9 10 11 12 13 14 15 16
  $webkit-images: ();
  $spec-images: ();

  @each $image in $images {
    $webkit-image: ();
    $spec-image: ();

    @if (type-of($image) == string) {
      $url-str:       str-slice($image, 0, 3);
      $gradient-type: str-slice($image, 0, 6);
17

18 19 20
      @if $url-str == "url" {
        $webkit-image: $image;
          $spec-image: $image;
21
      }
22 23 24 25 26

      @else if $gradient-type == "linear" {
        $gradients: _linear-gradient-parser($image);
        $webkit-image:  map-get($gradients, webkit-image);
        $spec-image:    map-get($gradients, spec-image);
27 28
      }

29 30 31 32 33
      @else if $gradient-type == "radial" {
        $gradients: _radial-gradient-parser($image);
        $webkit-image: map-get($gradients, webkit-image);
        $spec-image:   map-get($gradients, spec-image);
      }
34
    }
35 36 37

    $webkit-images: append($webkit-images, $webkit-image, comma);
    $spec-images:   append($spec-images,   $spec-image,   comma);
38 39
  }

40 41 42
  background-image: $webkit-images;
  background-image: $spec-images;
}