最佳答案
在 SVG 中,您可以使用多边形元素在正方形内创建三 Angular 形,并且每个多边形都可以单独悬停。
.square {
height: 400px;
width: 400px;
overflow: hidden;
}
svg {
height: 100%;
width: 100%;
}
polygon {
fill: aliceblue;
stroke: crimson;
stroke-linejoin: round;
}
polygon:hover {
fill: cornflowerblue;
}
<div class='square'>
<svg viewBox='0 0 100 100'>
<a xlink:href='http://google.com'>
<polygon points='5,5 50,50 95,5' />
</a>
<polygon points='5,5 50,50 5,95' />
<polygon points='5,95 50,50 95,95' />
<polygon points='95,5 50,50 95,95' />
</svg>
</div>
关于javascript - 创建交互式非矩形 HTML 元素的最佳方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44053909/