News for hackers. Stuff that matters.
Re:Learn SVG with 25 examples – How to code images in HTML by epiccoleman on Thursday December 07, 2023 @05:09PM (#38562508)
True - although in certain ways, this can be an advantage. When I've built SVG components, I use viewbox with height and width constants to define the SVG's "internal" dimensions, and then if you want to do something like finding the midpoint, you just do the right math on your constants. Then, the component can easily be scaled via CSS.

The problem, of course, is that there's not really a good way to do dynamic sizing if you want to be able to change the aspect ratio, which is where layout engines like Grid and Flex become so useful in HTML / CSS. But in my (fairly limited) experience, if I'm reaching for SVG it's because I need the tight control that comes with it, so it hasn't been an issue for my own projects.

Re:Learn SVG with 25 examples – How to code images in HTML by johnfn on Thursday December 07, 2023 @07:18PM (#38563740)
Yeah and, worse comes to worst, you can just use foreignObject to bounce back to HTML, do something with flexbox, and then go back to SVG!
Re:Learn SVG with 25 examples – How to code images in HTML by epiccoleman on Friday December 08, 2023 @08:14AM (#38568604)
Yeah - foreignObject is super interesting, I had never heard of it before this thread. I even have a potential use case for it one of my projects, definitely need to check it out.