svgscaleresponsivenessinline-svg

How can I make an inline SVG always fill out the screen?


I've created a vector image, which I'd like to use as a hero for my website. It should fill out the width and height of the viewport at all resolutions.

Furthermore I need to be able to animate the SVG's elements via CSS or JavaScript, so inserting it as a css background or an img isn't an option (at least as far as I know).

Do you guys know a way to solve this? This image shows, what I'd like to achieve: enter image description here

Any help would be greatly appreciated!


Solution

  • Got it to work, thanks to Robert Longson's comment: Applying preserveAspectRatio="xMidYMid slice" and 100% width & height to the SVG worked.

    You can see it here: http://codepen.io/EigenDerArtige/pen/yMaXZx