Change SVG Viewbox size with CSS -


the question: there way change size of svg viewbox css, preserve aspect ratio? or there way preserve aspect ratio of svg without view box.

the problem: want responsively adjust size of svg, keep aspect ratio. width of viewbox adjusts page, height doesn't adjust width. problem height of container div dependent on height of viewbox. container div may tall if there's nothing showing in bottom half of viewbox.

fiddle: http://jsfiddle.net/ht9jb/1/

<style>     div{         width: 100%;         height: 500px;         background-color: #00ffff;     }      svg{         width: 50%;         background-color: #ffff00;     } </style>  <div>     <svg version="1.1" id="layer_1" x="0px" y="0px" width="250px" height="400px" viewbox="0 0 250 400" enable-background="new 0 0 250 400" aspect-ratio="xminymin">         <rect x="0" y="0" fill="#ff0000" width="250" height="400"/>     </svg> </div> 

(object svgs , img svgs wont work purposes. has inline. solution doesn't have css...javascript acceptable solution.)

did try:

preserveaspectratio='xminymin' 

check example http://jsfiddle.net/ht9jb/3/

for more details, see mozila documentation svg


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -