In his RWD & SVG talk at RWD Summit in March 2016, Dudley Storey shares his thoughts on working with Scalable Vector Graphics for Responsive Web Design, especially on logos and icons. Here are my notes from his talk:
There are five rules when designing icons and logos in SVG:
- Design & build SVG icons&logos at the aprox target px for the screens (
~50x50px
for icons, as needed for logos) - Set up your illustration tool to help solve issues before they happen:
- Strokes in the middle of paths
- Exporting styles as CSS
- Use Boolean paths rather than superimposed layers
- SVG filters and not illustrator’s one (if illustrator)
- Draw icons
1px
in from the edge of the viewBox to allow for browser’s tendency to fractionally bloat SVG with antialiasing, which can be cut off if you draw too close to the edges- Optimize the SVG to remove redundant code
- SVGOMG
- Adobe Illustrator 2015.2
- Sketch Beta 3
- Since SVG is a replaced HTML element, linked CSS that does not load will leave an SVG element rendered at
300x150px
by default. Icons should have fallback width and height attributes: - Deal with IE
- It sets height for the SVG applied as a
150px
height and100%
width creating distortion. You can useimg {width: 100%;}
or safer withimg[src$=“.svg”] { width: 100%}
- Inline SVGs require a container element and a “padding hack”
- It sets height for the SVG applied as a