问题
I'm looking everywhere to answer this question but nowhere can I find anything about it. Can anyone tell me whether we can affect the area which received the item hover border-radius property. So that the effect of changes such as color took place after hitting a real area viewed item? Do not block that physically exists in the DOM as a square?
This is simple img.
and some simple fiddle: www.jsfiddle.net/nawAE
回答1:
Well, you can use SVG and pointer-events:
https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events?redirectlocale=en-US&redirectslug=CSS%2Fpointer-events
Or just use SVG, maybe with some framework like Raphäel.
Or maybe play with a map, let me try that...
http://jsfiddle.net/coma/nawAE/10/
HTML
<img class="div" src="http://images2.wikia.nocookie.net/__cb20100822143346/runescape/images/2/21/1x1-pixel.png" usemap="hack"/>
<map name="hack">
<area shape="circle" coords="200,200,200" />
</map>
JS
$('area').hover(function(event) {
$('img.div').toggleClass('hover');
});
LOOK MOM, NO JS:
http://jsfiddle.net/coma/nawAE/12/
.div {
display: block;
font-size: 0;
width: 400px;
height: 400px;
background-color: red;
border-radius: 50%;
}
map:hover + img {
background-color: blue;
}
More of that:
http://jsfiddle.net/coma/nawAE/16/
来源:https://stackoverflow.com/questions/16612439/border-radius-and-hover-state-area-issue