I have a division with hole in between, when I rotate it on direct hover it works; but when I try to rotate it while hovering on another division #btn
it doesn't work. I don't understand why?
I've made the hole using the :after
element;
Here's my code:
/* This Part doesn't work (#btn:hover>.hollowBox) */
#btn:hover>.hollowBox {
transform: perspective(800px) rotateY(25deg);
}
/* Following part works comment out the upper part and uncomment the code below */
/*.hollowBox:hover{
transform: perspective(800px) rotateY(25deg);
}*/
.hollowBox {
background: #ddd;
position: relative;
width: 60%;
height: 40%;
}
.hollowBox:after {
content: '';
position: absolute;
background: #222;
width: 80%;
height: 80%;
top: 10%;
left: 10%;
}
#btn {
background: wheat;
padding: 0.3em
}
body {
width: 100vw;
height: 100vh;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: #222;
}
<div class='hollowBox'></div><br><br>
<div id='btn'>Hover Me</div>