At 11:53 +0100 23/9/11, Jonathan Chetwynd wrote:

>CSS howto scale object to window and keep format?
>
>Is there a CSS method to scale an object (SVG) to say fill 100% either 
>width or height whichever is smaller?
>smaller may mean comparing format of image and window....
>
>I'm facing particular problems with object where the width and height 
>are specified in CSS rather than the element.
>and cannot find a means to scale, that relates the window format to 
>the svg format before scaling.
>a square svg object allows direct comparison of window height and 
>width...
>and might leave a gutter, on right if window is landscape or below
>when portrait.


So far as I know this cannot be done in the style sheet or in a style 
attribute, because what you need is the viewBox (note case!) etc. 
attributes of the svg object itself, which cannot be expressed as 
style.

I think this code does what you want:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
   "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd";>
<svg version="1.1" width="100%"
        viewBox="0 0 60 40"
        preserveAspectRatio="xMinYMin meet"
        xmlns="http://www.w3.org/2000/svg";
        xmlns:xlink="http://www.w3.org/1999/xlink";
        xmlns:ev="http://www.w3.org/2001/xml-events";>
<rect width="60" height="40"
        fill="salmon" fill-opacity=".3" />
<circle cx="30" cy="20" r="10" stroke-width=".3"
        stroke="black" fill="lightgray" />
</svg>

JD


------------------------------------

-----
To unsubscribe send a message to: [email protected]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
----Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/svg-developers/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to