scss Sass - Mixins:SVG背景图片
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了scss Sass - Mixins:SVG背景图片相关的知识,希望对你有一定的参考价值。
$image-path: '../img' !default;
$fallback-extension: 'png' !default;
$retina-suffix: '@2x';
@mixin background-image($name, $size:false){
background-image: url(#{$image-path}/#{$name}.svg);
@if($size){
background-size: $size;
}
.no-svg &{
background-image: url(#{$image-path}/#{$name}.#{$fallback-extension});
@media only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) {
background-image: url(#{$image-path}/#{$name}#{$retina-suffix}.#{$fallback-extension});
}
}
}
/* Usage */
body {
@include background-image('pattern');
}
以上是关于scss Sass - Mixins:SVG背景图片的主要内容,如果未能解决你的问题,请参考以下文章
scss Mixins Sass
scss CSS Flexbox - Sass Mixins
scss 用于媒体查询的Sass mixins
scss Mixins Sass
scss 因为只有sass mixins
scss CSS Flexbox - Sass Mixins