Svg image element not displaying in Safari -
safari browser (i'm testing under windows) seems having problem in displaying svg image element.
<!doctype html> <html> <body> <h1>my first svg</h1> <img src="image.svg" /> </body> </html>
and here content of image.svg:
<?xml version="1.0" encoding="utf-8" standalone="no"?> <!-- created inkscape (http://www.inkscape.org/) --> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <rect x="50" y="50" width="100" height="100" style="fill:blue"></rect> <rect id="foo" x="50" y="150" width="500" height="500" style="fill:green"></rect> <image x="50" y="10" width="200" height="200" xlink:href="data:image/png;base64,ivborw0kggoaaaansuheugaaaauaaaafcayaaacnbyblaaaaheleqvqi12p4//8/w38giaxdibke0dhxgljnbaao9txl0y4ohwaaaabjru5erkjggg=="></image> </svg>
is there solution or workaround make work in safari?
i think there 2 problems here:
you haven't said how large svg image is. rule, should @ least include
viewbox
attribute in<svg>
tag. example:<svg width="250" height="250" viewbox="0 0 250 250" ... >
the other problem safari isn't particularly brilliant @ rendering svgs. however, tends better when embed them
<iframe>
or<object>
tag instead of using<img>
. example:<object data="image.svg" type="image/svg+xml"></object>
also, make sure server delivering svg content correct mime type (
content-type: image/svg+xml
), can cause problems too.
so give try:
html source:
<!doctype html> <html> <body> <h1>my first svg</h1> <object data="image.svg" type="image/svg+xml"></object> </body> </html>
image.svg:
<?xml version="1.0" encoding="utf-8" standalone="no"?> <svg width="250" height="250" viewbox="0 0 250 250" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <rect x="50" y="50" width="100" height="100" style="fill:blue"></rect> <rect id="foo" x="50" y="150" width="500" height="500" style="fill:green"></rect> <image x="50" y="10" width="200" height="200" xlink:href="data:image/png;base64,ivborw0kggoaaaansuheugaaaauaaaafcayaaacnbyblaaaaheleqvqi12p4//8/w38giaxdibke0dhxgljnbaao9txl0y4ohwaaaabjru5erkjggg=="></image> </svg>
Comments
Post a Comment