[英]How to create SVG responsive polygon with points given in vw/vh units?
Let's say I have a triangle like in the example below. 假设我有一个三角形,如下例所示。 But the points are in pixels.
但是点以像素为单位。 I'm trying to use this triangle as a background element.
我正在尝试将此三角形用作背景元素。 Is it possible to pass those points in vw/vh units?
是否可以以vw / vh单位传递这些点?
<svg > <polygon className='svg1' points="50,0 100,100 100,0" /> </svg>
If you want a triangle background simply consider gradient like below: 如果您想使用三角形背景,只需考虑如下渐变:
body { margin:0; height:100vh; background:linear-gradient(to top right,transparent 49.5%,#000 50%); }
Or with SVG like that: 或像这样的SVG:
body { background:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100" preserveAspectRatio="none" ><polygon points="0,0 100,100 100,0" /></svg>') 0 0/100% 100%; margin:0; height:100vh; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.