• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Why is there a small gap under an absolutely-positioned SVG?

Resolved: Why is there a small gap under an absolutely-positioned SVG?

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I set up a div, the orange one
position:relative
and an SVG container absolutely positioned at the bottom. The SVG is just a triangle path in the middle of a 10×700 viewport
CSS code:
Sometimes, not always, during page rendering, the SVG is not exactly at the bottom, it’s some 0.8pixels on top, and an orange line of the bottom div can be seen, like the screenshot attached. This happens especially when chrome dev tools are open.
I tried almost everything.
The problem is that if I do
the orange line disappears, but the triangle’s bottom corner is cut by 1 pixel and became a trapezium
Am I missing something?
Thanks
glitch show

Answer:

This may sound weird, and it indeed seems to be a rendering bug, but the way I solve it is to set a -1px negative margin on the SVG. In your case, like:
This always seems to fix it for me.
If this still cuts stuff off, my guess is you can experiment with smaller (perhaps half-pixel even) values, but I consider the single pixel value as the smallest cross-browser-safe unit.
Additionally, you can try adding one pixel to both your SVG’s (viewbox) width and height, and then apply this trick in CSS.

If you have better answer, please add a comment about this, thank you!

css google-chrome html svg
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How do I use SetWindowText with Unicode in Win32 using PowerShell?

01/04/2023

Resolved: Shopware 400 Status Error “This value is too long. It should have 255 character or less.” When I Try Updating Database Table

01/04/2023

Resolved: Using AWK to count multiple patterns in a file

01/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.