English 中文(简体)
在特别志愿人员部分内分一个以上部分
原标题:Apply Gradient to more than one element inside an SVG Element

我正试图用特别志愿人员小组的分子制造一只arrow子:

“enterography

这是我的尝试:

“entergraph

由于你可以看到梯度同时适用于rect &我在SVG中采用了多角Is there a way toplica the gradient effect in the first fact in my SVG?

是否可能有特别安全局这样做? Maybe I HAVE to use a path or one polygon elements to establish the arrow than a rect & polygon?

<svg width="424" height="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(13,20,93);  stop-opacity:1" />
        </radialGradient>
    </defs>

    <rect x="0" y="25" rx="0" ry="0" width="212" height="50" fill="url(#grad1)"> </rect>
    <polygon points="212,0 212,100 424,50" fill="url(#grad1)"></polygon>
</svg>
最佳回答

我利用两个梯度试图重新计算你试图做的事情。 您可以调整梯度中心,使其与形状的边缘相一致:

<svg width="424" height="100">
    <defs>
        <radialGradient id="grad1" cx="100%" cy="50%" r="100%" fx="100%" fy="50%">
          <stop offset="0%" style="stop-color:rgb(255,255,255); stop-opacity:0" />
          <stop offset="100%" style="stop-color:rgb(13,20,93);  stop-opacity:1" />
        </radialGradient>
        <radialGradient id="grad2" cx="0%" cy="50%" r="50%" fx="0%" fy="50%">
          <stop offset="0%" style="stop-color:rgb(255,255,255); stop-opacity:0" />
          <stop offset="100%" style="stop-color:rgb(13,20,93);  stop-opacity:1" />
        </radialGradient>
    </defs>
    <rect x="0" y="25" rx="0" ry="0" width="212" height="50" fill="url(#grad1)"> </rect>
    <polygon points="212,0 212,100 424,50" fill="url(#grad2)"></polygon>
</svg>

rel=“nofollow>

http://jsfiddle.net/BFvCL/1/“rel=“nofollow” 否

<svg width="424" height="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(13,20,93);  stop-opacity:1" />
        </radialGradient>
    </defs>

    <polygon points="212,0 212,25 0,25 0,75, 212,75 212,100 424,50" fill="url(#grad1)"></polygon>
</svg>
问题回答

您可以“打破”两条形状的单一道路,然后将梯度应用于小组。

<svg
 xmlns:svg="http://www.w3.org/2000/svg"
 xmlns="http://www.w3.org/2000/svg"
 xmlns:xlink="http://www.w3.org/1999/xlink"
 version="1.1"
 width="424"
 height="100"
 id="svg2996">
 <defs>
 <radialGradient cx="0.5" cy="0.5" r="0.5" fx="0.5" fy="0.5" id="grad1">
  <stop style="stop-color:#ffffff;stop-opacity:0" offset="0" />
  <stop style="stop-color:#0d145d;stop-opacity:1" offset="1" />
 </radialGradient>
 <radialGradient cx="212" cy="50" r="212" fx="212" fy="50" id="radialGradient3809" xlink:href="#grad1"
 gradientUnits="userSpaceOnUse"
 gradientTransform="matrix(1,0,0,0.23584906,0,38.207547)" />
 </defs>
 <g style="fill:url(#radialGradient3809);fill-opacity:1">
  <rect width="212" height="50" rx="0" ry="0" x="0" y="25" />
  <polygon points="424,50 212,0 212,100 " />
 </g>
</svg>

https://codepen.io/anon/pen/QMGQ”rel=“nofollow noreferer”>codepen





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签