Answer the question
In order to leave comments, you need to log in
Centering inline svg?
I insert svg like this
<div class="icon"><svg><use xlink:href='images/icons.svg#icon'></use></svg></div>
Answer the question
In order to leave comments, you need to log in
use absolute positioning
.icon{
position: relative;
width: 40px;
height: 40px;
text-align: center;
}
.icon svg{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
display: inline-block;
width: 25px;
height: 25px;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question