viewBox
defines the coordinate systemviewBox
defines the aspect ratio, unless preserveAspectRatio="none"
viewBox
with no width
and height
makes the SVG scale to fill the entire area\
meter {
width: 15em; height: 3em;
--star-opacity: .2;
background: url('data:image/svg+xml,\
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">\
<text font-size="100" y=".8em" opacity="' var(--star-opacity, 1) '">★') 0 / auto 100%;
}
meter::-webkit-meter-optimum-value { /* ::-moz-meter-bar for Gecko */
--star-opacity: 1;
background: inherit;
}
😢 Nope 😢
url()
?@function inline-svg($content, $attr:'') { @return url('data:image/svg+xml,\ <svg xmlns="http://www.w3.org/2000/svg" #{$attr}>\ #{$content}</svg>'); }
@function svg-emoji($char, $attr:'') { @return inline-svg( '<text font-size="100" y=".8em" #{$attr}>#{$char}</text>', 'viewBox="0 0 100 100"'); }
meter {
width: 15em; height: 3em;
background: svg-emoji('★', 'opacity=".2"') 0 / auto 100%;
}
meter::-webkit-meter-optimum-value { /* ::-moz-meter-bar for Gecko */
background: svg-emoji('★') 0 / auto 100%;
}
Idea suggested by Amelia Bellamy-Royds
stroke-dasharray
lets you create custom dashed bordersstroke-dashoffset
lets you move them and is animatable!viewBox
or dimensions lets your SVG background occupy the entire elementstroke-dasharray: 0% 400% to 400% 400%
stroke-dasharray
accepts percentages, relative to sqrt(d²/2)0% 400%
to 400% 400%
makes the element draw progressively#
as %23
because it's a reserved character in URLsbaseFrequency, numOctaves, seed, scale, attributeName, dur, values, repeatCount
calc()
in geometry attributes, but no yet
<g style="filter: url(#scribble); stroke: black; stroke-width: 4px">
<line x2="100%" transform="translate(0 3)" />
<line y2="100%" transform="translate(3)" />
<line x1="100%" x2="100%" y2="100%" transform="translate(-3)" />
<line y1="100%" x2="100%" y2="100%" transform="translate(0 -3)" />
</g>
🤢🤮🤮
<feTurbulence>
generates a pseudo-random image<feDisplacementMap>
shifts pixels around based on the pixel values of another imageseed
of an <feTurbulence>
filter creates Squigglevision!filter
property, animation is disabled