里面有一些文字的图片。悬停时 svg 会更改背景颜色,除非将鼠标悬停在其中的文本上。
当鼠标悬停在文本上时,如何更改 svg-background?
<svg class="svg">
<polygon class="polygon" points="100,10 40,198 190,78 10,78 160,198">
</polygon>
<text class="number" x="85" y="115">456</text>
</svg>
.svg {
}
.svg .polygon {
fill: red;
}
.svg .polygon:hover {
fill: blue;
}
.svg .number {
font-size: 19px;
}
最佳答案
为此,您需要添加 pointer-events: none;
给你的<text>
标签。
CSS
.svg .number {
font-size: 19px;
pointer-events: none; /* <-- Add This */
}
关于javascript - 使用其中的文本更改 svg-image 中的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38704493/