Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make <svg> 100% width

Tags:

I am trying to make this <svg> element stretch to 100% of the screen width:

  <svg height="100" width="100">    <path d="M0 0 L100 0 L50 100 Z" />   </svg> 

What do I need to do?

like image 979
Marek Avatar asked Aug 15 '15 20:08

Marek


1 Answers

The viewBox defines the co-ordinates you can see. Height and width define the size of the SVG. E.g.

html, body {    width: 100%;    height: 100%;  }
<svg height="100%" width="100%" viewBox="0 0 100 100"  preserveAspectRatio="none">     <path d="M0 0 L100 0 L50 100 Z" />  </svg>
like image 87
Robert Longson Avatar answered Oct 05 '22 02:10

Robert Longson