JavaScript Width of SVG isn't correct when viewBox is defined max-width isn't working,css width isn'

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.

enter image description here

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>
Answer:1

View Port

-The viewport is the visible area of an <svg>. To set viewport we can use attributes height and width with <svg>.

View Box

-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.

Example

If we set viewport and viewbox, width and height same. Then viewbox cover entire image.

Solution

-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

Answer:2

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.

enter image description hereenter image description here

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>
Answer:3

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.

Answer:4

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.

screenshot

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>
Answer:5

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 ...

  1. skype entry point not found
  2. skype entry point not found error
  3. skype entry point not found ffmpeg.dll
  4. skype entry point
  5. skype entry point not found avcodec_decode_audio4
  6. skype entry point not found windows 7
  7. skype entry point not found iphlpapi.dll
  8. skype.exe entry point not found
  9. skype.exe entry point not found windows 10
  10. skype procedure entry point
  11. skype.exe entry point not found fix
  12. skype.exe entry point not found windows xp
  13. skype procedure entry point not found
  14. skype.exe entry point not found iphlpapi.dll
  15. skype no entry point
  16. skype the procedure entry point avcodec_decode_audio4
  17. skype for business entry point not found
  18. skype.exe the procedure entry point ntdll.dll
  19. lỗi skype entry point not found

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. ...

  1. angularjs change active tab

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 ...

  1. react onsubmit is not a function
  2. react form onsubmit do nothing

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"> ...

  1. source from video tag
  2. source video from
  3. find source from video
  4. source video html
  5. source video maker
  6. source video calgary
  7. source video html5
  8. source video editor
  9. source video interview
  10. source video youtube
  11. source video edmonton
  12. source video games
  13. source video 4k
  14. source video finder
  15. source video interview questions
  16. source video download
  17. source video type
  18. source video vlc obs
  19. source video facebook
  20. source video js