【发布时间】:2018-01-09 20:25:39
【问题描述】:
我正在尝试制作一个内部有 4 个椭圆的 svg,它们重叠。它工作正常,但当屏幕尺寸变小时,它似乎反应不佳。我应该怎么做才能让它响应?
这是我目前对 svg 元素的 sn-p:
<div class="row">
<div class="col-md-12">
<svg height="220" width="100%">
<defs>
<radialGradient id="grad1" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
<stop offset="0%" style="stop-color:rgb(255,255,255);
stop-opacity:0" />
<stop offset="100%" style="stop-color:rgb(0,0,255);stop-opacity:1" />
</radialGradient>
</defs>
<ellipse cx="125" cy="110" rx="95" ry="85" fill="url(#grad1)" />
<defs>
<radialGradient id="grad1" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
<stop offset="0%" style="stop-color:rgb(255,255,255);
stop-opacity:0" />
<stop offset="100%" style="stop-color:rgb(0,0,255);stop-opacity:1" />
</radialGradient>
</defs>
<ellipse cx="300" cy="110" rx="95" ry="85" fill="url(#grad1)" />
<defs>
<radialGradient id="grad1" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
<stop offset="0%" style="stop-color:rgb(255,255,255);
stop-opacity:0" />
<stop offset="100%" style="stop-color:rgb(0,0,255);stop-opacity:1" />
</radialGradient>
</defs>
<ellipse cx="475" cy="110" rx="95" ry="85" fill="url(#grad1)" />
<defs>
<radialGradient id="grad1" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
<stop offset="0%" style="stop-color:rgb(255,255,255);
stop-opacity:0" />
<stop offset="100%" style="stop-color:rgb(0,0,255);stop-opacity:1" />
</radialGradient>
</defs>
<ellipse cx="650" cy="110" rx="95" ry="85" fill="url(#grad1)" />
</div>
</div>
这在手机屏幕上:
【问题讨论】:
-
您缺少结束 svg 标记。但这并不能解决问题。
-
你可以从这个解决方案中找到提示stackoverflow.com/questions/25940741/making-svg-responsive
-
确实如此。视口是要走的路。
标签: html svg bootstrap-4