最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - non-rectangular hoverable area - Stack Overflow

programmeradmin7浏览0评论

I would like to have an arrow which will do something on :hover but only when the arrow itself is hovered (not the rectangle which delimits its width and height).

In short, when you hover on the right-bottom and right-top corners of an ► it shouldn't do anything.

How would I achieve that?

I would like to have an arrow which will do something on :hover but only when the arrow itself is hovered (not the rectangle which delimits its width and height).

In short, when you hover on the right-bottom and right-top corners of an ► it shouldn't do anything.

How would I achieve that?

Share Improve this question edited Aug 16, 2018 at 21:43 Machavity 31.7k27 gold badges95 silver badges105 bronze badges asked Jul 16, 2011 at 7:46 KnuKnu 15.2k6 gold badges59 silver badges92 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

With a HTML map element? See < map >.

Update:

For example, like in this demo:

img {
  border: 3px solid black;
}
<br />
<img id="img" src="http://upload.wikimedia/wikipedia/mons/thumb/3/3c/Black_triangle.svg/200px-Black_triangle.svg.png" usemap="#triangle" alt="" />
<map name="triangle">
    <area shape="poly" coords="3, 3, 195, 3, 100, 169"
        href="http://google." alt=""
        onmouseover="document.getElementById('img').style.borderColor = 'red';"
        onmouseout="document.getElementById('img').style.borderColor = 'black';"/>
</map>

You can either use oldschool imagemaps or track mousemovement throught the mousemove event and then do x/y coordinate calculations.

发布评论

评论列表(0)

  1. 暂无评论