Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Sizing SVG in HTML

Reply
Thread Tools

Sizing SVG in HTML

 
 
Tom
Guest
Posts: n/a
 
      09-09-2005
Is there any way to show a SVG in a HTML in different sizes by changing
the
width and height attributes of the object/embed tag?

Assume a simple SVG like

<svg width="100" height="100">
<rect x="0" y="0" width="100" height="100"
style="fill:none;stroke:black"/>
<svg>

which is embeded in a HTML page like

<object type="image/svg+xml" data="simple.svg"
width="100" height="100">
<embed type="image/svg+xml" src="simple.svg"
width="100" height="100"></embed>
</object>

the SVG is always shown at size 100x100 no matter what I provide for
HTML width and height. Is there anything I can put into my SVG to make
it custom sizable?
I know I could write
<svg width="100%" height="100%">
<rect x="0%" y="0%" width="100%" height="100%"
style="fill:none;stroke:black"/>
<svg>
But that is not ok for me, except for the initial SVG width and height
attributes.

__
Tom

 
Reply With Quote
 
 
 
 
Joris Gillis
Guest
Posts: n/a
 
      09-09-2005
Hi,

Tempore 14:06:28, die Friday 09 September 2005 AD, hinc in foro {comp.text.xml} scripsit Tom <(E-Mail Removed)>:

> Is there any way to show a SVG in a HTML in different sizes by changing
> the
> width and height attributes of the object/embed tag?


I'm not an expert on the topic of SVG, but I'll try to help.

Instead of specifying the width and height on the svg element, specify the viewBox:

<svg viewBox="0 0 100 100">
<rect x="0" y="0" width="100" height="100"
style="fill:none;stroke:black"/>
<svg>

Now you should be able to scale it via HTML syntax.

regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Deserta faciunt et innovationem appelant
 
Reply With Quote
 
 
 
 
Tom
Guest
Posts: n/a
 
      09-09-2005
Yes! Thank you.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: svg-chart 1.1 SVG Charting Library Helmut Jarausch Python 0 05-20-2008 11:05 AM
svg to svg saving problem milof83 Java 1 08-18-2006 07:36 PM
[SVG] probleme dessin d'images SVG avec Batik Mardagg Java 0 05-12-2006 02:13 PM
[SVG] problem with SVG image drawing with Batik Library Mardagg Java 0 05-12-2006 02:12 PM
[SVG] using image-tag to integrate SVG in SVG Arne Nordmann XML 0 06-28-2004 01:16 PM



Advertisments