<div class="g-container">
<ul class="g-bg">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<div class="g-content" style="--polygon: 30% 10%, 75% 1%, 94% 51%, 71% 94%, 44% 60%, 8% 50%"></div>
</div>
<div class="g-container">
<ul class="g-bg">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<div class="g-content" style="--polygon: 43% 36%, 69% 12%, 99% 50%, 71% 94%, 30% 90%, 5% 50%"></div>
</div>
@property --per {
syntax: '<percentage> | <angle>';
inherits: false;
initial-value: 360deg;
}
body, html {
width: 100%;
height: 100%;
display: flex;
}
.g-container {
position: relative;
width: 300px;
height: 300px;
cursor: pointer;
margin: auto;
flex-shrink: 0;
}
.g-bg {
position: absolute;
inset: 0;
&::after {
content: "";
position: absolute;
inset: 20px 0;
z-index: 6;
background:
linear-gradient(transparent, transparent calc(50% - .5px), #333 calc(50% - .5px), #333 calc(50% + .5px), transparent calc(50% + .5px), transparent),
linear-gradient(120deg, transparent, transparent calc(50% - 1px), #333 calc(50% - .5px), #333 calc(50% + .5px), transparent calc(50% + 1px), transparent),
linear-gradient(240deg, transparent, transparent calc(50% - 1px), #333 calc(50% - .5px), #333 calc(50% + .5px), transparent calc(50% + 1px), transparent);
clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}
li {
position: absolute;
width: 150px;
height: 260px;
background: #fff;
filter:
drop-shadow(0 0 .5px #333)
drop-shadow(0 0 .5px #333)
drop-shadow(0 0 .5px #333);
translate: -50% -50%;
left: 50%;
top: 50%;
&::before,
&::after {
content: "";
position: absolute;
inset: 0;
background: inherit;
}
&::before {
transform: rotate(120deg);
}
&::after {
transform: rotate(240deg);
}
}
@for $i from 1 to 5 {
li:nth-child(#{$i}) {
z-index: #{$i};
width: #{(1 - $i / 5) * 150}px;
height: #{(1 - $i / 5) * 260}px;
}
}
}
.g-content {
position: absolute;
inset: 20px 0;
z-index: 10;
mask: conic-gradient(#000, #000 var(--per), transparent var(--per), transparent 360deg);
&:hover {
animation: hoverPie 600ms ease-in-out;
}
&::before {
content: "";
position: absolute;
inset: 0;
background: linear-gradient(rgba(241,94,174, .8), rgba(255, 152, 0, .8));
clip-path: polygon(var(--polygon));
}
}
@keyframes hoverPie {
0% {
--per: 0deg;
}
100% {
--per: 360deg;
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.