L
L
lavezzi12016-04-08 16:26:49
css
lavezzi1, 2016-04-08 16:26:49

How to use svg sprites in TARS on less?

I use the tars assembly, threw the svg images into img / svg, the process has begun. The following is formed in the svg-sprites.less file:

@add-plus-hover: -4px -4px 32px 33px 40px 61px './test.svg' 'add-plus-hover';
  @add-plus: -4px -41px 16px 16px 40px 61px './test.svg' 'add-plus';

.svg-sprite-position(@svg-sprite) {
  @svg-sprite-offset-x: ~`"@{svg-sprite}".split(', ')[0].replace('[', '')`;
  @svg-sprite-offset-y: ~`"@{svg-sprite}".split(', ')[1]`;
  background-position: @svg-sprite-offset-x  @svg-sprite-offset-y;
}

.bg-svg(@svg-sprite, @repeat: no-repeat) {
    background-image: url('%=static=%svg-sprite/sprite.svg');
    .svg-sprite-position(@svg-sprite);
    width: ~`"@{svg-sprite}".split(', ')[2]`;
    height: ~`"@{svg-sprite}".split(', ')[3]`;

    background-repeat: @repeat;
}

And how to use it? For sass it's clear, like this @include bg-svg(); And for less how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Shirokuiu, 2017-07-06
@Shirokuiu

.bg-svg(@svg-image-name);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question