I create a sprite using gulp (plugin gulp-svg-sprites). In Mozilla it is displayed normally, in chrome I open - everything is shifted. enter image description here If I generate a png-sprite from the final svg (gulp-svg2png plugin) and connect it instead of svg, then it is displayed normally in all browsers. those. I understand that this is due to the interpretation of the browser.

How to fix?

An example of my sprite after the galp is here . When you change the size of the slider in chrome, this bug can also be seen (clearly visible at maximum magnification, on white when to invert the background).

In the moody all is normal.

PS Updated sprite - set that all elements of the viewBox begin with "0 0 " Did not help.

Gulp settings:

 gulp.task('svg-sprites:build', function () { return gulp.src(options.theme.img_svg_src + '*.svg') .pipe(svgSprite()) .pipe(gulp.dest(options.theme.img_src + 'dict')) .pipe(filter(options.theme.img_src + 'dict/svg/*.svg')) .pipe(gulp.dest(options.theme.img_src + 'dict')); }); 
  • one
    Thanks to everyone who participated. Choosing a winner is a difficult task. Therefore, I decided to do this: Each answer received from me + 1 vote. The cronfy response was the first to solve my problem very quickly, so I marked it as correct. At the time of the end of the competition, Vadizar's answer is correct and most complete (in my opinion), so I noted it as a winner ... - Alex

4 answers 4

Short answer

Remove the viewBox="0 0 41 2023" attribute from the SVG. However, you can also delete the rest viewbox. You can do this automatically using svgo ( removeViewBox plugin).

Long answer

This is similar to Chrome background-size calculation when the background-size horizontally is not a multiple of the width of the viewBox in the SVG.

See, your background-size is set in em: 4.1em 202.3em (sprite.css: 5). A change in the size of images is set via font-size from 2 to 14 px. The initial font-size value is 10px, so when you open the page, the size of the background in pixels is 41x2023 px, just like the viewBox in the SVG. You can set the background-size: 41px 2023px and everything will remain the background-size: 41px 2023px .

But if you specify a pixel smaller: background-size: 40px 2023px , we will see an offset vertically. Although it would seem, the picture should be just a little bit already.

Therefore, when changing the font, everything goes. If you set the font size to 11px, then the background width will be 4.1em * 11px = 45.1px , and this is not a multiple of 41 (the width of the original viewBox). The next font value at which everything is shown is normal - 20px: the horizontal background-size becomes 82px, which is a multiple of 41.

I definitely do not undertake to describe all the features of this bug (sometimes it manifests itself, sometimes it does not), but the point is that the solution is simple: remove the viewBox="0 0 41 2023" attribute from the SVG. However, you can also delete the rest viewBox .

You can do this automatically using svgo ( removeViewBox plugin). Example for gulp :

 gulp.task('remove-viewbox', function() { var svgmin = require('gulp-svgmin'); return gulp.src('src/*.svg') .pipe(svgmin({ plugins: [ {removeViewBox: true} ] })) .pipe(gulp.dest('dest/')); }); 

    You've probably already guessed that in Chrome you see, along with the main icon, the bottom of the previous icon. There can be many reasons, but there are two main ones:

    1. Each browser has its own styles, so it’s better to reset them with a separate reset.css file from Eric Meier, or use Normalize.css , read the translation of the article here .
    2. The second, main reason is the selection of icons with different proportions.

    For some, width="7" height="7" viewBox="0 0 7 7 , for others viewBox="231 233 38 34 You see, here you had to move the icon using the viewBox. And further, if you look, run the SVG file of the sprite locally, you will see large spaces, these are just the icons that do not fall within the line of sight.

    To avoid such risks and misunderstandings, it may be easier to find SVG icons with the same attributes. There are a lot of such collections in the network, where they are directly sorted by size 32x32; 64x64; 128x128 ...

    • one
      Normalize is used on the site itself - the situation does not change ... because of large gaps - these are white pictures and cannot be seen in normal viewing (although if you set the background in the browser's code inspector, you can see everything). Regarding the standard ones, I took many pictures from different libraries, I draw some myself (the designer’s site, the old version of the sprite is posted here) .... I will try to make the viewbox a zero angle for everyone ... tell me how you can do it quickly ... maybe there is Any plugin to normalize svg? - Alex
    • @Alex but what does zero angle mean? For viewBox = "0 0 32 32" The first two null parameters are x / y coordinates - Alexandr_TT
    • To normalize SVG, there are plugins, but they reduce the number of decimal places and remove official garbage after vector editors, but do not touch the viewBox. Look at the utility that Qwertiy wrote can suit you. Stackoverflow.com/questions/627684/… - Alexandr_TT
    • and what is this utility? where can I see it? I saw a link - Alex
    • @Alexandr_T normalize such nonsense. It does not remove the outline, and in this case it will not solve anything. - Vadizar

    Option 1: Deleting ViewBox Source Files

    Use the gulp-imagemin and imagemin-svgo plugins to remove the ViewBox:

     var gulp = require('gulp'), svg-sprites = require('gulp-svg-sprites'), imagemin = require('gulp-imagemin'), imageminSvgo = require('imagemin-svgo'); gulp.task('svg-sprites:build', function () { return gulp.src(options.theme.img_svg_src + '*.svg') .pipe(imagemin([ imageminSvgo({ plugins: [ {removeViewBox: true} ] }) ])) .pipe(svgSprite()) .pipe(gulp.dest(options.theme.img_src + 'dict')) .pipe(filter(options.theme.img_src + 'dict/svg/*.svg')) .pipe(gulp.dest(options.theme.img_src + 'dict')); }); 

    Option 2: replace the SVG sprite with the icon font

    It would be preferable to use the iconic font instead of sprites. And this method has several advantages:

    1. Lower font weight than sprite;
    2. CSS styling flexibility;
    3. Less weight CSS.

    To generate an icon font, I would advise this combination:

     // Generate icon font gulp.task('iconfont', function() { var fontName = 'icon-font', cssClass = 'i'; // Исходные SVG-файлы gulp.src(['./fonts/icon-font/*.svg']) .pipe(iconfontCss({ fontName: fontName, cssClass: cssClass, path: './styl/mixins/icon-font.styl', targetPath: '../../styl/components/font/icon-font.styl', fontPath: '../fonts/' })) .pipe(iconfont({ fontName: fontName, prependUnicode: true, normalize: true, formats: ['svg','ttf','woff','woff2'] })) .pipe(gulp.dest('./public/fonts/')); }); 

    Bowls for styles that come from this line path: './styl/mixins/icon-font.styl' will look like this:

     @font-face font-family "<%= fontName %>" src: url('<%= fontPath %><%= fontName %>.woff2') format('woff2'), url('<%= fontPath %><%= fontName %>.woff') format('woff'), url('<%= fontPath %><%= fontName %>.ttf') format('truetype'), url('<%= fontPath %><%= fontName %>.svg#<%= fontName %>') format('svg') [class*="i-"] position relative display inline-block width 1em height 1em &:before font 14px '<%= fontName %>' font-size inherit text-rendering auto speak none font-variant normal text-transform none color inherit position absolute top 50% left 50% transform translate(-50%, -50%) <% _.each(glyphs, function(glyph) { %> .<%= cssClass %>-<%= glyph.fileName %>:before content "\<%= glyph.codePoint %>" <% }); %> 

    After generating the font, all you need to do is connect the generated CSS to your site or ingress it to the main CSS file, and then use it like this:

     <span class="i-<<имя исходного SVG-файла>>"></span> 
    • @Alexandr_T, I do not understand what you mean. - Vadizar
    • one
      @Alexandr_T I personally have one voice left and I just gave it to you. It is not necessary to accuse me of minus. I myself today on all issues someone massively minus. - Vadizar
    • Maybe because I gave the answer later? - Vadizar
    • @Alexandr_T and why are you minus me? - Vadizar

    I took your sprite and, for clarity, I formatted the code a little, without changing its essence. Notice that the viewport attributes that usually do not indicate are responsible for the vertical spaces between the icons, since by default they are x = "0" y = "0" - this is the upper left corner. In your version, for the first icon, y = "0", for the second icon - y = "32", then y = "64" That is, the vertical positioning solely depends on these parameters.

      <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="41" height="2023" viewBox="0 0 41 2023" style="background:#000"><svg viewBox="0 0 32 32" width="32" height="32" id="a-we-in-facebook" y="0"> <path fill="#FFF" d="M19.8 6.5h5.5V.8h-5.5c-4.2 0-7.7 2.9-7.7 6.7v2.8H7.7V16h4.4v15.2h6.6V16h5.5l1.1-5.7h-6.6V7.5c0-.5.5-1 1.1-1z"> </path> </svg> <svg viewBox="0 0 32 32" width="32" height="32" id="a-we-in-google" y="32"> <path fill="#FFF" d="M1.7 8.3c0 2.5.9 4.5 2.6 5.6 1.4.8 3.1 1 4 1h.5s-.3 1.7 1.1 3.5c-2.4 0-9.9.5-9.9 6.5 0 6.1 6.9 6.4 8.3 6.4h.5c.9 0 3.2-.1 5.3-1.1 2.7-1.2 4.1-3.6 4.1-6.7s-2.1-4.9-3.7-6.2c-.9-.8-1.8-1.5-1.8-2.2 0-.7.6-1.2 1.4-1.9 1.2-1 2.4-2.5 2.4-5.5 0-2.4-.3-4.2-2.4-5.4.2-.1 1-.2 1.4-.2 1.1-.2 2.7-.3 2.7-1.2V.8H10c-.1 0-8.3.2-8.3 7.5zM15 24c.2 2.4-2 4.2-5.2 4.5-3.3.2-6-1.2-6.1-3.7-.1-1.1.5-2.3 1.5-3.3S7.7 20 9.3 20h.6c2.9 0 4.9 1.7 5.1 4zM12.8 6.7c.8 2.8-.4 5.6-2.3 6.2h-.7c-1.8 0-3.5-1.7-4.2-4.2-.3-1.3-.2-2.5.1-3.7.4-1.1 1.1-1.9 2.1-2.1.2 0 .4-.1.6-.1 2.2 0 3.6.9 4.4 3.9zm13.9 5.8V7.2h-3.6v5.3h-5.3V16h5.3v5.3h3.6V16H32v-3.5h-5.3z"></path> </svg> <svg viewBox="0 0 32 32" width="32" height="32" id="a-we-in-instagram" y="64"> <path fill="#FFF" d="M16.5 15c0-.3-.2-.5-.5-.5-1.5 0-2.7 1.1-2.7 2.5 0 .3.2.5.5.5s.5-.2.5-.5c0-.8.8-1.5 1.6-1.5.4 0 .6-.2.6-.5zm3.8 2c0 2.2-2 4-4.3 4s-4.3-1.8-4.3-4 1.9-4 4.3-4 4.3 1.9 4.3 4zM3 26.1h26V24H3v2.1zM22.5 17c0-3.4-2.9-6.1-6.6-6.1S9.4 13.6 9.4 17s2.9 6.1 6.6 6.1 6.5-2.8 6.5-6.1zM5.3 6.9h6.6V4.8H5.3v2.1zM3 9.9h26v-4H15L13.9 8H3v1.9zm28.2-4v20.3c0 1.1-1 2.1-2.2 2.1H3c-1.2 0-2.2-.9-2.2-2.1V5.9c0-1.1 1-2.1 2.2-2.1h26c1.2 0 2.2.9 2.2 2.1z"></path> </svg> <svg viewBox="0 0 32 32" width="32" height="32" id="a-we-in-twitter" y="96"> <path fill="#FFF" d="M30.8 5.2c-1.1.6-2.3.9-3.5 1.1 1.2-.8 2.3-2.4 2.6-4-1.2.8-2.4 1.4-3.9 1.8-1.1-1.4-2.6-2.4-4.4-2.4-3.3 0-6 3.2-6 7.2 0 .6.1 1 .2 1.6-5-.3-9.5-3.1-12.5-7.5-.6 1-.9 2.4-.9 3.6 0 2.5 1 4.7 2.6 6-.9 0-1.9-.4-2.7-.8v.1c0 3.5 2.1 6.4 4.9 7.1-.6.2-1 .3-1.6.3-.4 0-.8-.1-1.1-.1.8 2.8 3 4.9 5.7 5-2.1 2-4.7 3.1-7.5 3.1-.6 0-.9 0-1.5-.1 2.6 2.1 5.9 3.2 9.3 3.2 11.2 0 17.2-11 17.2-20.5v-.8c1.2-1.2 2.2-2.4 3.1-3.9z"></path> </svg> <svg viewBox="0 0 32 32" width="32" height="32" id="a-we-in-vcontacte" y="128"> <path fill="#FFF" d="M22.6 15.1c1.1-1.5 1.9-3.4 1.9-5.6 0-4.7-3.6-8.6-8-8.6h-10V31h12c4.4 0 8-3.9 8-8.6 0-3.1-1.5-5.8-3.9-7.3zM12.5 5.3h3.2c1.8 0 3.2 2 3.2 4.3s-1.4 4.3-3.2 4.3h-3.2V5.3zm4.9 21.4h-5v-8.6h5c1.9 0 3.3 2 3.3 4.3s-1.4 4.3-3.3 4.3z"></path> </svg> </svg> 

    The first solution is to increase the gaps between the icons, that is, increase Y At the bottom, as you see, you see almost no gap between the icons. In the second example, the gap is increased by 8px; y = 0; 40; 80; 120

     <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="41" height="2023" viewBox="0 0 41 2023" style="background:#000"><svg viewBox="0 0 32 32" width="32" height="32" id="a-we-in-facebook" y="0"> <path fill="#FFF" d="M19.8 6.5h5.5V.8h-5.5c-4.2 0-7.7 2.9-7.7 6.7v2.8H7.7V16h4.4v15.2h6.6V16h5.5l1.1-5.7h-6.6V7.5c0-.5.5-1 1.1-1z"> </path> </svg> <svg viewBox="0 0 32 32" width="32" height="32" id="a-we-in-google" y="40"> <path fill="#FFF" d="M1.7 8.3c0 2.5.9 4.5 2.6 5.6 1.4.8 3.1 1 4 1h.5s-.3 1.7 1.1 3.5c-2.4 0-9.9.5-9.9 6.5 0 6.1 6.9 6.4 8.3 6.4h.5c.9 0 3.2-.1 5.3-1.1 2.7-1.2 4.1-3.6 4.1-6.7s-2.1-4.9-3.7-6.2c-.9-.8-1.8-1.5-1.8-2.2 0-.7.6-1.2 1.4-1.9 1.2-1 2.4-2.5 2.4-5.5 0-2.4-.3-4.2-2.4-5.4.2-.1 1-.2 1.4-.2 1.1-.2 2.7-.3 2.7-1.2V.8H10c-.1 0-8.3.2-8.3 7.5zM15 24c.2 2.4-2 4.2-5.2 4.5-3.3.2-6-1.2-6.1-3.7-.1-1.1.5-2.3 1.5-3.3S7.7 20 9.3 20h.6c2.9 0 4.9 1.7 5.1 4zM12.8 6.7c.8 2.8-.4 5.6-2.3 6.2h-.7c-1.8 0-3.5-1.7-4.2-4.2-.3-1.3-.2-2.5.1-3.7.4-1.1 1.1-1.9 2.1-2.1.2 0 .4-.1.6-.1 2.2 0 3.6.9 4.4 3.9zm13.9 5.8V7.2h-3.6v5.3h-5.3V16h5.3v5.3h3.6V16H32v-3.5h-5.3z"></path> </svg> <svg viewBox="0 0 32 32" width="32" height="32" id="a-we-in-instagram" y="80"> <path fill="#FFF" d="M16.5 15c0-.3-.2-.5-.5-.5-1.5 0-2.7 1.1-2.7 2.5 0 .3.2.5.5.5s.5-.2.5-.5c0-.8.8-1.5 1.6-1.5.4 0 .6-.2.6-.5zm3.8 2c0 2.2-2 4-4.3 4s-4.3-1.8-4.3-4 1.9-4 4.3-4 4.3 1.9 4.3 4zM3 26.1h26V24H3v2.1zM22.5 17c0-3.4-2.9-6.1-6.6-6.1S9.4 13.6 9.4 17s2.9 6.1 6.6 6.1 6.5-2.8 6.5-6.1zM5.3 6.9h6.6V4.8H5.3v2.1zM3 9.9h26v-4H15L13.9 8H3v1.9zm28.2-4v20.3c0 1.1-1 2.1-2.2 2.1H3c-1.2 0-2.2-.9-2.2-2.1V5.9c0-1.1 1-2.1 2.2-2.1h26c1.2 0 2.2.9 2.2 2.1z"></path> </svg> <svg viewBox="0 0 32 32" width="32" height="32" id="a-we-in-twitter" y="120"> <path fill="#FFF" d="M30.8 5.2c-1.1.6-2.3.9-3.5 1.1 1.2-.8 2.3-2.4 2.6-4-1.2.8-2.4 1.4-3.9 1.8-1.1-1.4-2.6-2.4-4.4-2.4-3.3 0-6 3.2-6 7.2 0 .6.1 1 .2 1.6-5-.3-9.5-3.1-12.5-7.5-.6 1-.9 2.4-.9 3.6 0 2.5 1 4.7 2.6 6-.9 0-1.9-.4-2.7-.8v.1c0 3.5 2.1 6.4 4.9 7.1-.6.2-1 .3-1.6.3-.4 0-.8-.1-1.1-.1.8 2.8 3 4.9 5.7 5-2.1 2-4.7 3.1-7.5 3.1-.6 0-.9 0-1.5-.1 2.6 2.1 5.9 3.2 9.3 3.2 11.2 0 17.2-11 17.2-20.5v-.8c1.2-1.2 2.2-2.4 3.1-3.9z"></path> </svg> <svg viewBox="0 0 32 32" width="32" height="32" id="a-we-in-vcontacte" y="160"> <path fill="#FFF" d="M22.6 15.1c1.1-1.5 1.9-3.4 1.9-5.6 0-4.7-3.6-8.6-8-8.6h-10V31h12c4.4 0 8-3.9 8-8.6 0-3.1-1.5-5.8-3.9-7.3zM12.5 5.3h3.2c1.8 0 3.2 2 3.2 4.3s-1.4 4.3-3.2 4.3h-3.2V5.3zm4.9 21.4h-5v-8.6h5c1.9 0 3.3 2 3.3 4.3s-1.4 4.3-3.3 4.3z"></path> </svg> </svg> 
    Given that in your version you are rigidly tied to the positioning of the icons inside the sprite and as it turns out this can lead to unpredictable effects, you can suggest -

    Second option

    Make a classic sprite using <symbol> tags and <use> call commands from a sprite.

     <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="300" height="200" viewBox="0 0 300 200" style="background:#000; border:1px solid red;"> <symbol id="a-we-in-facebook"> viewBox="0 0 32 32" width="32" height="32" > <path fill="#FFF" d="M19.8 6.5h5.5V.8h-5.5c-4.2 0-7.7 2.9-7.7 6.7v2.8H7.7V16h4.4v15.2h6.6V16h5.5l1.1-5.7h-6.6V7.5c0-.5.5-1 1.1-1z"> </path> </symbol> <symbol id="a-we-in-google"> viewBox="0 0 32 32" width="32" height="32" > <path fill="#FFF" d="M1.7 8.3c0 2.5.9 4.5 2.6 5.6 1.4.8 3.1 1 4 1h.5s-.3 1.7 1.1 3.5c-2.4 0-9.9.5-9.9 6.5 0 6.1 6.9 6.4 8.3 6.4h.5c.9 0 3.2-.1 5.3-1.1 2.7-1.2 4.1-3.6 4.1-6.7s-2.1-4.9-3.7-6.2c-.9-.8-1.8-1.5-1.8-2.2 0-.7.6-1.2 1.4-1.9 1.2-1 2.4-2.5 2.4-5.5 0-2.4-.3-4.2-2.4-5.4.2-.1 1-.2 1.4-.2 1.1-.2 2.7-.3 2.7-1.2V.8H10c-.1 0-8.3.2-8.3 7.5zM15 24c.2 2.4-2 4.2-5.2 4.5-3.3.2-6-1.2-6.1-3.7-.1-1.1.5-2.3 1.5-3.3S7.7 20 9.3 20h.6c2.9 0 4.9 1.7 5.1 4zM12.8 6.7c.8 2.8-.4 5.6-2.3 6.2h-.7c-1.8 0-3.5-1.7-4.2-4.2-.3-1.3-.2-2.5.1-3.7.4-1.1 1.1-1.9 2.1-2.1.2 0 .4-.1.6-.1 2.2 0 3.6.9 4.4 3.9zm13.9 5.8V7.2h-3.6v5.3h-5.3V16h5.3v5.3h3.6V16H32v-3.5h-5.3z"></path> </symbol> <symbol id="a-we-in-instagram" viewBox="0 0 32 32" width="32" height="32" > <path fill="#FFF" d="M16.5 15c0-.3-.2-.5-.5-.5-1.5 0-2.7 1.1-2.7 2.5 0 .3.2.5.5.5s.5-.2.5-.5c0-.8.8-1.5 1.6-1.5.4 0 .6-.2.6-.5zm3.8 2c0 2.2-2 4-4.3 4s-4.3-1.8-4.3-4 1.9-4 4.3-4 4.3 1.9 4.3 4zM3 26.1h26V24H3v2.1zM22.5 17c0-3.4-2.9-6.1-6.6-6.1S9.4 13.6 9.4 17s2.9 6.1 6.6 6.1 6.5-2.8 6.5-6.1zM5.3 6.9h6.6V4.8H5.3v2.1zM3 9.9h26v-4H15L13.9 8H3v1.9zm28.2-4v20.3c0 1.1-1 2.1-2.2 2.1H3c-1.2 0-2.2-.9-2.2-2.1V5.9c0-1.1 1-2.1 2.2-2.1h26c1.2 0 2.2.9 2.2 2.1z"></path> </symbol> <symbol id="a-we-in-twitter" viewBox="0 0 32 32" width="32" height="32" > <path fill="#FFF" d="M30.8 5.2c-1.1.6-2.3.9-3.5 1.1 1.2-.8 2.3-2.4 2.6-4-1.2.8-2.4 1.4-3.9 1.8-1.1-1.4-2.6-2.4-4.4-2.4-3.3 0-6 3.2-6 7.2 0 .6.1 1 .2 1.6-5-.3-9.5-3.1-12.5-7.5-.6 1-.9 2.4-.9 3.6 0 2.5 1 4.7 2.6 6-.9 0-1.9-.4-2.7-.8v.1c0 3.5 2.1 6.4 4.9 7.1-.6.2-1 .3-1.6.3-.4 0-.8-.1-1.1-.1.8 2.8 3 4.9 5.7 5-2.1 2-4.7 3.1-7.5 3.1-.6 0-.9 0-1.5-.1 2.6 2.1 5.9 3.2 9.3 3.2 11.2 0 17.2-11 17.2-20.5v-.8c1.2-1.2 2.2-2.4 3.1-3.9z"></path> </symbol> <symbol id="a-we-in-vcontacte" viewBox="0 0 32 32" width="32" height="32" > <path fill="#FFF" d="M22.6 15.1c1.1-1.5 1.9-3.4 1.9-5.6 0-4.7-3.6-8.6-8-8.6h-10V31h12c4.4 0 8-3.9 8-8.6 0-3.1-1.5-5.8-3.9-7.3zM12.5 5.3h3.2c1.8 0 3.2 2 3.2 4.3s-1.4 4.3-3.2 4.3h-3.2V5.3zm4.9 21.4h-5v-8.6h5c1.9 0 3.3 2 3.3 4.3s-1.4 4.3-3.3 4.3z"></path> </symbol> <use y="50" xlink:href="#a-we-in-facebook"></use> <use y="50" x="50" xlink:href="#a-we-in-google"></use> <use y="50" x="100" xlink:href="#a-we-in-instagram"></use> <use y="50" x="150" xlink:href="#a-we-in-twitter"></use> <use y="50" x="200" xlink:href="#a-we-in-vcontacte"></use> </svg> 
    This option allows you to position the icons using the x, y coordinates in the <use> command and looks the same in all browsers.

    Option with icons in one block, with minimal indents

      <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="235" height="45" viewBox="0 0 235 45" style="background:#000; border:1px solid red;"> <symbol id="a-we-in-facebook"> viewBox="0 0 32 32" width="32" height="32" > <path fill="#FFF" d="M19.8 6.5h5.5V.8h-5.5c-4.2 0-7.7 2.9-7.7 6.7v2.8H7.7V16h4.4v15.2h6.6V16h5.5l1.1-5.7h-6.6V7.5c0-.5.5-1 1.1-1z"> </path> </symbol> <symbol id="a-we-in-google"> viewBox="0 0 32 32" width="32" height="32" > <path fill="#FFF" d="M1.7 8.3c0 2.5.9 4.5 2.6 5.6 1.4.8 3.1 1 4 1h.5s-.3 1.7 1.1 3.5c-2.4 0-9.9.5-9.9 6.5 0 6.1 6.9 6.4 8.3 6.4h.5c.9 0 3.2-.1 5.3-1.1 2.7-1.2 4.1-3.6 4.1-6.7s-2.1-4.9-3.7-6.2c-.9-.8-1.8-1.5-1.8-2.2 0-.7.6-1.2 1.4-1.9 1.2-1 2.4-2.5 2.4-5.5 0-2.4-.3-4.2-2.4-5.4.2-.1 1-.2 1.4-.2 1.1-.2 2.7-.3 2.7-1.2V.8H10c-.1 0-8.3.2-8.3 7.5zM15 24c.2 2.4-2 4.2-5.2 4.5-3.3.2-6-1.2-6.1-3.7-.1-1.1.5-2.3 1.5-3.3S7.7 20 9.3 20h.6c2.9 0 4.9 1.7 5.1 4zM12.8 6.7c.8 2.8-.4 5.6-2.3 6.2h-.7c-1.8 0-3.5-1.7-4.2-4.2-.3-1.3-.2-2.5.1-3.7.4-1.1 1.1-1.9 2.1-2.1.2 0 .4-.1.6-.1 2.2 0 3.6.9 4.4 3.9zm13.9 5.8V7.2h-3.6v5.3h-5.3V16h5.3v5.3h3.6V16H32v-3.5h-5.3z"></path> </symbol> <symbol id="a-we-in-instagram" viewBox="0 0 32 32" width="32" height="32" > <path fill="#FFF" d="M16.5 15c0-.3-.2-.5-.5-.5-1.5 0-2.7 1.1-2.7 2.5 0 .3.2.5.5.5s.5-.2.5-.5c0-.8.8-1.5 1.6-1.5.4 0 .6-.2.6-.5zm3.8 2c0 2.2-2 4-4.3 4s-4.3-1.8-4.3-4 1.9-4 4.3-4 4.3 1.9 4.3 4zM3 26.1h26V24H3v2.1zM22.5 17c0-3.4-2.9-6.1-6.6-6.1S9.4 13.6 9.4 17s2.9 6.1 6.6 6.1 6.5-2.8 6.5-6.1zM5.3 6.9h6.6V4.8H5.3v2.1zM3 9.9h26v-4H15L13.9 8H3v1.9zm28.2-4v20.3c0 1.1-1 2.1-2.2 2.1H3c-1.2 0-2.2-.9-2.2-2.1V5.9c0-1.1 1-2.1 2.2-2.1h26c1.2 0 2.2.9 2.2 2.1z"></path> </symbol> <symbol id="a-we-in-twitter" viewBox="0 0 32 32" width="32" height="32" > <path fill="#FFF" d="M30.8 5.2c-1.1.6-2.3.9-3.5 1.1 1.2-.8 2.3-2.4 2.6-4-1.2.8-2.4 1.4-3.9 1.8-1.1-1.4-2.6-2.4-4.4-2.4-3.3 0-6 3.2-6 7.2 0 .6.1 1 .2 1.6-5-.3-9.5-3.1-12.5-7.5-.6 1-.9 2.4-.9 3.6 0 2.5 1 4.7 2.6 6-.9 0-1.9-.4-2.7-.8v.1c0 3.5 2.1 6.4 4.9 7.1-.6.2-1 .3-1.6.3-.4 0-.8-.1-1.1-.1.8 2.8 3 4.9 5.7 5-2.1 2-4.7 3.1-7.5 3.1-.6 0-.9 0-1.5-.1 2.6 2.1 5.9 3.2 9.3 3.2 11.2 0 17.2-11 17.2-20.5v-.8c1.2-1.2 2.2-2.4 3.1-3.9z"></path> </symbol> <symbol id="a-we-in-vcontacte" viewBox="0 0 32 32" width="32" height="32" > <path fill="#FFF" d="M22.6 15.1c1.1-1.5 1.9-3.4 1.9-5.6 0-4.7-3.6-8.6-8-8.6h-10V31h12c4.4 0 8-3.9 8-8.6 0-3.1-1.5-5.8-3.9-7.3zM12.5 5.3h3.2c1.8 0 3.2 2 3.2 4.3s-1.4 4.3-3.2 4.3h-3.2V5.3zm4.9 21.4h-5v-8.6h5c1.9 0 3.3 2 3.3 4.3s-1.4 4.3-3.3 4.3z"></path> </symbol> <use y="8" xlink:href="#a-we-in-facebook"></use> <use y="8" x="50" xlink:href="#a-we-in-google"></use> <use y="8" x="100" xlink:href="#a-we-in-instagram"></use> <use y="8" x="150" xlink:href="#a-we-in-twitter"></use> <use y="8" x="200" xlink:href="#a-we-in-vcontacte"></use> </svg> 

    The red frame is the SVG border, only for viewing, it can be removed - border:1px solid red; I used it to adjust indents.

    UPD 02.23.2017

    In addition, the SVG block of social icons with working links to social networks. Performance tested in: chrome, FF, Opera, Yandex

     <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="235" height="45" viewBox="0 0 235 45" style="background:black; "> <style> svg path{ fill:inherit; } #a-we-in-facebook, #a-we-in-google, #a-we-in-instagram, #a-we-in-twitter, #a-we-in-vcontacte { fill:inherit; } a:link { fill:white; } a:focus, a:active, a:hover { fill:orange; } </style> <symbol id="a-we-in-facebook"> viewBox="0 0 32 32" width="32" height="32" > <path d="M19.8 6.5h5.5V.8h-5.5c-4.2 0-7.7 2.9-7.7 6.7v2.8H7.7V16h4.4v15.2h6.6V16h5.5l1.1-5.7h-6.6V7.5c0-.5.5-1 1.1-1z"> </path> </symbol> <symbol id="a-we-in-google"> viewBox="0 0 32 32" width="32" height="32" > <path d="M1.7 8.3c0 2.5.9 4.5 2.6 5.6 1.4.8 3.1 1 4 1h.5s-.3 1.7 1.1 3.5c-2.4 0-9.9.5-9.9 6.5 0 6.1 6.9 6.4 8.3 6.4h.5c.9 0 3.2-.1 5.3-1.1 2.7-1.2 4.1-3.6 4.1-6.7s-2.1-4.9-3.7-6.2c-.9-.8-1.8-1.5-1.8-2.2 0-.7.6-1.2 1.4-1.9 1.2-1 2.4-2.5 2.4-5.5 0-2.4-.3-4.2-2.4-5.4.2-.1 1-.2 1.4-.2 1.1-.2 2.7-.3 2.7-1.2V.8H10c-.1 0-8.3.2-8.3 7.5zM15 24c.2 2.4-2 4.2-5.2 4.5-3.3.2-6-1.2-6.1-3.7-.1-1.1.5-2.3 1.5-3.3S7.7 20 9.3 20h.6c2.9 0 4.9 1.7 5.1 4zM12.8 6.7c.8 2.8-.4 5.6-2.3 6.2h-.7c-1.8 0-3.5-1.7-4.2-4.2-.3-1.3-.2-2.5.1-3.7.4-1.1 1.1-1.9 2.1-2.1.2 0 .4-.1.6-.1 2.2 0 3.6.9 4.4 3.9zm13.9 5.8V7.2h-3.6v5.3h-5.3V16h5.3v5.3h3.6V16H32v-3.5h-5.3z"></path> </symbol> <symbol id="a-we-in-instagram" viewBox="0 0 32 32" width="32" height="32" > <path d="M16.5 15c0-.3-.2-.5-.5-.5-1.5 0-2.7 1.1-2.7 2.5 0 .3.2.5.5.5s.5-.2.5-.5c0-.8.8-1.5 1.6-1.5.4 0 .6-.2.6-.5zm3.8 2c0 2.2-2 4-4.3 4s-4.3-1.8-4.3-4 1.9-4 4.3-4 4.3 1.9 4.3 4zM3 26.1h26V24H3v2.1zM22.5 17c0-3.4-2.9-6.1-6.6-6.1S9.4 13.6 9.4 17s2.9 6.1 6.6 6.1 6.5-2.8 6.5-6.1zM5.3 6.9h6.6V4.8H5.3v2.1zM3 9.9h26v-4H15L13.9 8H3v1.9zm28.2-4v20.3c0 1.1-1 2.1-2.2 2.1H3c-1.2 0-2.2-.9-2.2-2.1V5.9c0-1.1 1-2.1 2.2-2.1h26c1.2 0 2.2.9 2.2 2.1z"></path> </symbol> <symbol id="a-we-in-twitter" viewBox="0 0 32 32" width="32" height="32" > <path d="M30.8 5.2c-1.1.6-2.3.9-3.5 1.1 1.2-.8 2.3-2.4 2.6-4-1.2.8-2.4 1.4-3.9 1.8-1.1-1.4-2.6-2.4-4.4-2.4-3.3 0-6 3.2-6 7.2 0 .6.1 1 .2 1.6-5-.3-9.5-3.1-12.5-7.5-.6 1-.9 2.4-.9 3.6 0 2.5 1 4.7 2.6 6-.9 0-1.9-.4-2.7-.8v.1c0 3.5 2.1 6.4 4.9 7.1-.6.2-1 .3-1.6.3-.4 0-.8-.1-1.1-.1.8 2.8 3 4.9 5.7 5-2.1 2-4.7 3.1-7.5 3.1-.6 0-.9 0-1.5-.1 2.6 2.1 5.9 3.2 9.3 3.2 11.2 0 17.2-11 17.2-20.5v-.8c1.2-1.2 2.2-2.4 3.1-3.9z"></path> </symbol> <symbol id="a-we-in-vcontacte" viewBox="0 0 32 32" width="32" height="32" > <path d="M22.6 15.1c1.1-1.5 1.9-3.4 1.9-5.6 0-4.7-3.6-8.6-8-8.6h-10V31h12c4.4 0 8-3.9 8-8.6 0-3.1-1.5-5.8-3.9-7.3zM12.5 5.3h3.2c1.8 0 3.2 2 3.2 4.3s-1.4 4.3-3.2 4.3h-3.2V5.3zm4.9 21.4h-5v-8.6h5c1.9 0 3.3 2 3.3 4.3s-1.4 4.3-3.3 4.3z"></path> </symbol> <a xlink:href="https://ru-ru.facebook.com/"> <use y="8" xlink:href="#a-we-in-facebook"></use> </a> <a xlink:href="https://plus.google.com/" > <use y="8" x="50" xlink:href="#a-we-in-google"></use></a> <a xlink:href="https://www.instagram.com/" ><use y="8" x="100" xlink:href="#a-we-in-instagram"></use></a> <a xlink:href="https://twitter.com/" ><use y="8" x="150" xlink:href="#a-we-in-twitter"></use></a> <a xlink:href="https://vk.com/feed" ><use y="8" x="200" xlink:href="#a-we-in-vcontacte"></use></a> </svg> 

    • Option 1 can insure that parts of neighboring images will not fall, but the screen will still have a cropped image ... if you make more empty space around the image, then the desired image will be shown completely, but there will be problems with vertical alignment in different browsers with respect to the rest of the text .... The 2nd option is for the extreme case, because it is used by the CMS and it will recycle many templates ... and also a lot of work has been done ... it is easier to use png sprite as per old fashioned but want to use to take advantage of vector graphics ... - Alex
    • @Alex and take advantage of vector graphics. I so unobtrusively hinted that you can use my option. After all, this is a separate SVG file that can be inserted as a whole, as a block in HTML and the icons will look like they are, they do not need to be positioned additionally, the images will not be cut off, etc. but the links to the social. Networks can be inserted inside this SVG block. Use this file as a finished brick in your project - Alexandr_TT
    • @Alex look another option - social. icons in one block - Alexandr_TT
    • @Alex is another option with working links to social networks inside the SVG block. Now it is completely autonomous. - Alexandr_TT