How Media Queries Allow You to Optimize SVG Icons for Several Sizes
One thing that seems to come up from time to time when talking about SVG is the apparent lack of a mechanism to make certain size specific adjustments. Typical use case is icon design, where you want to make sure the outline of the icon you’re creating is always 1px, regardless of the icon being 16, 32 or 64 pixels in size.
While at the SVG Open conference last week, I investigated how this problem could be solved, and found out that you can do this by using media queries inside the SVG file. Different
widths set on the
img tag pointing to the SVG file then will trigger different
min-width media queries to be triggered.
I’ve presented my findings during the lightning talks session at SVG Open, and have turned the talk into a YouTube video, which you can watch below.