Hover and click on CSS triangle

前端 未结 4 1330
孤城傲影
孤城傲影 2020-12-05 20:48

I have a triangle with a javascript function that moves that image.

The issue is that the element has a square shape so click and hover state are triggered o

4条回答
  •  旧时难觅i
    2020-12-05 21:34

    You should be able to just use an image map. Just create one poly that covers the triangle by setting the coords to (w/2, 0), (w, h), (0, h) where w and h are width and height. (Assuming an equilateral triangle like in your example. Otherwise just find the points with an image editor.)

    
    
    
        
    
    

    Demo: http://jsfiddle.net/QXv2c/

提交回复
热议问题