Y
Y
Yaroslav Studenikin2021-10-16 23:49:34
css
Yaroslav Studenikin, 2021-10-16 23:49:34

svg content full width and height?

Gulp and plugins create svg sprite. in the layout I use the construction:

<svg class="socials__icon socials__icon--twitter">
                    <use xlink:href="img/sprite.svg#twitter"></use>
                </svg>

I found that when describing styles for icons (I write styles referring directly to the svg tag), the graphic part of the icons does not correspond to this size. There is little experience with svg, and nothing was found on Google on this issue.
616b3a1289f4c215794790.png
In particular: I set fixed dimensions of 26x26 for svg. And its content is 19.5x19.5
616b3a8af2485693039892.png
How can I achieve full width and height? Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
arsenty, 2021-10-18
@arsenty

Keep in mind that there should be a gap between the canvas border and the elements on it, otherwise, if you somehow get the canvas width/height fully filled with the icon, you may find visual bugs when rendering the page, depending on the browser.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question