OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <style> |
| 3 svg { height: 200px } |
| 4 </style> |
| 5 <body> |
| 6 <script> |
| 7 var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); |
| 8 rect.setAttribute('width', '100'); |
| 9 rect.setAttribute('height', '100'); |
| 10 rect.setAttribute('fill', 'green'); |
| 11 var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); |
| 12 svg.appendChild(rect); |
| 13 svg.setAttribute('viewBox', '0 0 200 100'); |
| 14 svg.setAttribute('preserveAspectRatio', 'xMinYMin'); |
| 15 svg.width.baseVal.valueAsString = '200'; |
| 16 document.body.appendChild(svg); |
| 17 </script> |
OLD | NEW |