Greetings to all the problem-solving magicians out there! I've found myself in a bit of a pickle that has turned into a staring contest with VS Code. It's been quite the showdown, haha.
So here's the deal - I created a fancy website UI in Adobe XD. To add some life to my design, I exported certain elements as SVG and hopped over to HTML & CSS. Now, the issue I'm facing is with text labels inside these SVG elements. In Adobe XD, I meticulously aligned the text centrally along the horizontal axis of the shapes. But lo and behold, when I check the design in a browser, all the text seems to have taken a detour to the left, beyond the confines of my beautiful shapes. Here's an example snippet:
<svg xmlns="http://www.w3.org/2000/svg" width="172" height="239" viewBox="0 0 172 239">
// The rest of your SVG code goes here
I scoured the depths of the internet for solutions, dabbling with text-anchor
and dominant-baseline
tags, but alas, no luck. Tweaking the x
and y
values did squat too. And don't even get me started on aligning multiline texts using <tspan>
. It feels like chasing a unicorn.