I'm encountering difficulties making the :hover
state work with a CSS pie slice that I created. Using transparent borders and the border-radius
property, I managed to style my div to resemble 1/4 of a pie. But no matter what styles I attempt for the hover effect, they just won't take hold. I suspect that the issue lies in the fact that the div has height: 0;
and width: 0;
, but I'm unsure how to resolve this... Here is the code snippet:
div {
position: absolute;
right: 0;
left: 0;
margin: 0 auto;
width: 0;
height: 0;
border-radius: 50%;
}
.circle-1 {
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 50px solid transparent;
border-top: 50px solid green;
}
.circle-1:hover {
border-top: 50px solid pink;
cursor: pointer;
}
.circle-2 {
border-left: 50px solid transparent;
border-right: 50px solid red;
border-bottom: 50px solid transparent;
border-top: 50px solid transparent;
}
.circle-3 {
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 50px solid blue;
border-top: 50px solid transparent;
}
.circle-4 {
border-left: 50px solid orange;
border-right: 50px solid transparent;
border-bottom: 50px solid transparent;
border-top: 50px solid transparent;
}
<div class="circle-1"></div>
<div class="circle-2"></div>
<div class="circle-3"></div>
<div class="circle-4"></div>