Hover event on hidden part of div
I have the following html example with css. My question is that when I move my mouse over the top cones of the parent html element the hover role becomes active. But it doesn't have to be, because it is a hidden part of the parent. It works correctly in firefox, but not in chrome, opera, that is, or in edge.
Any suggestions?
Is this a browser related bug or is it working as intended?
If I remove the position properties from the css then it works correctly but is not an option.
.perent{
top: 0px;
right: 0px;
width: 500px;
height: 500px;
background-color:red;
border-radius:50%;
overflow:hidden;
position:relative;
}
.child{
width: 1000px;
height: 200px;
background-color:blue;
position:absolute;
}
.child:HOVER{
background-color:black;
}
<div class="perent">
<div class="child">
</div>
</div>
+3
source to share
2 answers
Although I'm not sure if this is a browser bug or not, but I can suggest using svg
body {
margin: 0;
}
svg {
height: 100vh;
}
.child:hover {
fill: black;
}
<svg viewbox="0 0 100 100">
<defs>
<clipPath id="clipPath">
<circle r="50" cx="50" cy="50"/>
</clipPath>
</defs>
<rect class="child" x="0" y="0" width="100" height="40" fill= "blue" clip-path="url(#clipPath)"/>
<rect x="0" y="40" width="100" height="60" fill="red" clip-path="url(#clipPath)"/>
</svg>
+1
source to share