我有一个SVG圆,它内部有一个小的svg圆,小圆内有一个多边形,当我点击它应该旋转的多边形时,它的工作正常,但旋转后,工具提示应该出现在多边形的上方我不知道如何表达,我把它放在我上面的SVG一个div,这里是我的代码:如何在点击SVG后显示工具提示?
document.querySelector('polygon').addEventListener('click', function() {
this.classList.toggle('rotated');
});
.rotated {
transform: rotate(-90deg);
}
polygon {
transition: all 1s;
}
<div class="marker marker-index-0" style="display: none;">
<h3>I should be a tooltip</h3>
</div>
<svg>
<circle cx="40" cy="122.5" r="26" fill="red"></circle>
<g class="markerG" transform="matrix(1,0,0,1,40,122.5)"><circle cx="0" cy="0" r="14" fill="#000000" style="cursor: pointer;"></circle><polygon points="1 -1 1 -7 -1 -7 -1 -1 -7 -1 -7 1 -1 1 -1 7 1 7 1 1 7 1 7 -1" fill="#ffffff"></polygon></g>
</svg>
为了澄清,你不必与工具提示任何代码 - 这是更多的什么是隐藏和显示工具提示的最佳方式问题的? – aug
是的,这就是它的要点 – jessica