将鼠标悬停在父项上时更改 SVG 多边形和文本填充颜色

Change SVG polygon and text fill colours when hovering over parent

我有一个正在努力解决的小难题.. 当您将鼠标悬停在父级 div 上时,试图让多边形填充颜色和文本填充颜色都发生变化。这可以通过 CSS 实现吗?想避免 javascript 并保持跨浏览器兼容。

此处为 Codepen 示例:

http://codepen.io/okass/pen/OXAXkY

<svg viewBox="-1 -1 255 53"><a href="#">
<g id="cta-button">
  <polygon class="polygon-cta" points="252.72209 0 197.614579 51 0 51 0 0"></polygon>
  <text class="text-cta">
      <tspan x="22" y="34">Learn more</tspan>
  </text>
</g>
</a>

当您将鼠标悬停在#cta-button 上时,我不知道如何将文本填充更改为白色...当您将鼠标悬停在文本上时,它会按预期工作,但当鼠标悬停在多边形上时,文本会隐藏.

将文本颜色更改移动到 parent 组悬停状态时触发。

svg #cta-button:hover text{
  fill: #fff;
}

#cta-button {
  fill: transparent;
  stroke: #e9004b;
}
svg text {
  font-weight: bold;
  font-size: 26px;
  font-family: lato;
  fill: #E9004B;
  stroke: none;
}
#cta-button:hover {
  fill: #e9004b;
}
svg #cta-button:hover text {
  fill: #fff;
}
<svg viewBox="-1 -1 255 53">
  <a href="#">
    <g id="cta-button">
      <polygon class="polygon-cta" points="252.72209 0 197.614579 51 0 51 0 0"></polygon>
      <text class="text-cta">
        <tspan x="22" y="34">Learn more</tspan>
      </text>
    </g>
  </a>
</svg>