How to position svg that underlines a text properly

I have to get this svg positioned rigth below the text (with a min space between the text and the svg) and it has to follow the size of the text (which changes according to the width of the screen) By now the svg is positioned like this: Html: <h2 class="dark-olive-text bolder"> <span>¡Así, juntos hacemos un </span> <span class="underlined-element">mundo mejor!</span> </h2> Css: /*The variable that sets the font size and is used in my h2*/ --font-size-title-page: clamp(2.5rem, 5vw, 3.75rem); .underlined-element::after { content: url('../img/underline.svg'); position: relative; bottom: clamp(3vh, 4vh + 1vw, 7vh); left: 7.5vw; width: 7vw; height: auto; } This way seems a bit tricky to me, and on mobile screens the svg is way above from where it's supposed to be (it can be seen on the picture I uploaded). Would love some help with this, been scratching my head over it for too long now 😄
No description
No description
2 Replies
Zoë
Zoë8mo ago
Use em to position the line as it will change with the font-size and so it should stay in the same position
ἔρως
ἔρως8mo ago
also, instead of using an svg, you may want to consider using clip-path you might want to convert the path to a polygon for that, but it works the same-ish