Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
139
rated 0 times [  145] [ 6]  / answers: 1 / hits: 29008  / 11 Years ago, tue, january 14, 2014, 12:00:00

I have the following div inside <body>.



<div style=width:320px; height:480px;>
<svg id=svg1></svg>
</div>


I want to fit a 640X480 svg inside this div. I have tried this:



var paper=Snap(#svg1);
Snap.load(somesvg.svg,function(f){
paper.append(f);
});
paper.attr({
width:320, height:480
})


But the svg is cut off from the right size.


More From » html

 Answers
0

I was wondering about adjusting the viewBox for this, so something like...



<div style=width:320px; height:480px;>
<svg id=svg1 width=100% height=100% viewBox=0 0 640 480 preserveAspectRatio=xMaxYMax></svg>
</div>


jsfiddle http://jsfiddle.net/9zRR8/5/


[#73188] Monday, January 13, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jazmyne

Total Points: 503
Total Questions: 102
Total Answers: 99

Location: Svalbard and Jan Mayen
Member since Sun, Sep 25, 2022
2 Years ago
;