문제

i need to create polygon which will be responsive to any screen resolution and it will be always fully stretched to screen.

I started with this demo but as you can see it is woriking only for fixed width (1000px) of screen.

Is it possible to set polygon's coordinates with percentage units or is there any other way how to accomplish that?

도움이 되었습니까?

해결책

You need to set a viewBox rather than a fixed width and height.

<svg xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 1000 20" preserveAspectRatio="none" width="100%" height="100%">

  <polygon points="0,0  1000,0  500,20"
         style="fill:#cc3333;"/>

</svg>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top