I am trying to understand why my SVG icon is not rendered correctly. The icon is a little smallest that my SVG element event if the viewBox property was used the same like width\height.
Thanks for any help
As you see the icon is a little bit smallest than the whole SVG element.
My SVG code.
<svg width="24" height="25" viewBox="0 0 24 25" xmlns="http://www.w3.org/2000/svg">
<title>1FB31B20-CDD9-43CB-A743-1C613F5D5E0C</title>
<g fill="#9FA09F" fill-rule="evenodd">
<path d="M7 13.684a6 6 0 1 0 0-12 6 6 0 0 0 0 12zm0 1a7 7 0 1 1 0-14 7 7 0 0 1 0 14z" />
<path d="M7 7.684a2 2 0 1 0 .001-4 2 2 0 0 0-.001 4zM7 8.684c3 0 3.566 2.116 3.566 2.116.24.488-.019.884-.563.884H3.997c-.55 0-.82-.418-.553-.9 0 0 .556-2.1 3.556-2.1z" />
</g>
</svg>
-The viewport is the visible area of an <svg>
. To set viewport we can use attributes height
and width
with <svg>
.
-It allow us to set our graphic and stretch to fit within container. viewbox
having four property mix-x
, min-y
, width
, height
. And min
values represent from what point within the image the viewBox
should start.
If we set viewport and viewbox
, width
and height
same. Then viewbox
cover entire image.
-For your problem you need to reduce size of viewbox
width
an height
property. But as your image size is small you also need to set width
and `height to get required result.
JsFiddle Solution with different example
If you created the icon, it was draw on the top left corner of the canvas. The actual icon is a 14px x 15px
inside a 24px x 25px
viewbox.
If this was the case, you could either re-draw it centered full width and height of a 24px x 25px
workspace canvas or if you can't re-draw it just try to align it manually as it is.
Anyways, if you wish the latter, here's a flex suggestion to align it with CSS translate
(tweak values to your benefit):
.container {
display: flex;
}
svg {
transform: translate(25%, 20%);
}
<div class="container">
<svg width="24" height="25" viewBox="0 0 24 25" xmlns="http://www.w3.org/2000/svg">
<title>1FB31B20-CDD9-43CB-A743-1C613F5D5E0C</title>
<g fill="#9FA09F" fill-rule="evenodd">
<path d="M7 13.684a6 6 0 1 0 0-12 6 6 0 0 0 0 12zm0 1a7 7 0 1 1 0-14 7 7 0 0 1 0 14z" />
<path d="M7 7.684a2 2 0 1 0 .001-4 2 2 0 0 0-.001 4zM7 8.684c3 0 3.566 2.116 3.566 2.116.24.488-.019.884-.563.884H3.997c-.55 0-.82-.418-.553-.9 0 0 .556-2.1 3.556-2.1z" />
</g>
</svg>
<input type="text">
</div>
Your drawing seems to occupy a space much smaller than the viewBox area, just reduce the viewBox size to whatever you need it to be.
The reason why your icon appears to be offset is because it is not 24 × 25 pixels. The actual bounds of the vector are 14 × 14 pixels.
I would use an SVG editing tool to fine-tune your vector. The vector that you are currently using is very unstable. I had issues opening it up as-is.
I went ahead and tuned your vector and utilized actual circle and arc-paths.
Here is the result. The original vector is a 32 pixel SVG.
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
<title>1FB31B20-CDD9-43CB-A743-1C613F5D5E0C</title>
<g id="person-in-circle">
<circle id="circle" cx="16" cy="16" r="15" fill="none"
stroke="#9FA09F" stroke-width="2" stroke-linejoin="round" />
<g id="person" fill="#9FA09F">
<circle id="person-head" cx="16" cy="12" r="5" />
<path id="person-shoulders" d="M 24 24 a8,8 0 1,0 -16,0" />
</g>
</g>
</svg>
I'am trying to sign into Skype via the use of its SDK but I keep hitting the following error, "Error: NoFQDN". After searching this on the net I can't find any possible solution or even find out what ...
I'am trying to sign into Skype via the use of its SDK but I keep hitting the following error, "Error: NoFQDN". After searching this on the net I can't find any possible solution or even find out what ...
I have researched this issue and have found solutions using php but not angular. One of the requirements for saving the data on my page requires that two seperate angular objects have the same Id. ...
I have researched this issue and have found solutions using php but not angular. One of the requirements for saving the data on my page requires that two seperate angular objects have the same Id. ...
I'm currently working on a project using webpack and babel to build a project. I tried so many things as I can think of, but somehow onSubmit or onClick function do not work no matter how I bind those ...
I'm currently working on a project using webpack and babel to build a project. I tried so many things as I can think of, but somehow onSubmit or onClick function do not work no matter how I bind those ...
Im really new to JavaScript and I started a new project that consists in a video player and editor. I have this modal Box: <div class="modal" id="myModal"> <div class="modal-header"> ...
Im really new to JavaScript and I started a new project that consists in a video player and editor. I have this modal Box: <div class="modal" id="myModal"> <div class="modal-header"> ...