<div class="container">
<div class="container__items">
<input type="radio" name="stars" id="st5">
<label for="st5">
<div class="star-stroke">
<div class="star-fill"></div>
</div>
<div class="label-description" data-content="Excellent"></div>
</label>
<input type="radio" name="stars" id="st4">
<label for="st4">
<div class="star-stroke">
<div class="star-fill"></div>
</div>
<div class="label-description" data-content="Good"></div>
</label>
<input type="radio" name="stars" id="st3">
<label for="st3">
<div class="star-stroke">
<div class="star-fill"></div>
</div>
<div class="label-description" data-content="OK"></div>
</label>
<input type="radio" name="stars" id="st2">
<label for="st2">
<div class="star-stroke">
<div class="star-fill"></div>
</div>
<div class="label-description" data-content="Bad"></div>
</label>
<input type="radio" name="stars" id="st1">
<label for="st1">
<div class="star-stroke">
<div class="star-fill"></div>
</div>
<div class="label-description" data-content="Terrible"></div>
</label>
</div>
</div>
:root{
--primary-colour: #191919;
--secondary-colour: hsl(233 80% 70%);
--star-colour: hsl(38 90% 55%);
}
*{
margin: 0;
padding: 0;
transition: .3s;
box-sizing: border-box;
}
body{
width: 100vw;
height: 100vh;
overflow: hidden;
background: var(--primary-colour);
font-family: sans-serif;
color: #fff;
}
.container{
position: relative;
top: 50%;
left: 50%;
width: 40%;
height: 20%;
transform: translate(-50%, -50%) rotateY(180deg);
}
.container .container__items{
display: flex;
align-items: center;
justify-content: center;
gap: 0 .5em;
width: 100%;
height: 100%;
}
.container .container__items input{
display: none;
}
.container .container__items label{
width: 20%;
aspect-ratio: 1;
cursor: pointer;
}
.container .container__items label .star-stroke{
display: grid;
place-items: center;
width: 100%;
height: 100%;
background: var(--secondary-colour);
clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.container .container__items label .star-stroke .star-fill{
width: 70%;
aspect-ratio: 1;
background: var(--primary-colour);
clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.container .container__items input:hover ~ label .star-stroke,.container .container__items input:checked ~ label .star-stroke{
background: var(--star-colour);
}
.container .container__items input:checked ~ label .star-stroke .star-fill{
background: var(--star-colour);
}
.container .container__items label:hover .label-description::after{
content: attr(data-content);
position: fixed;
left: 0;
right: 0;
margin-top: 1em;
margin-inline: auto;
width: 100%;
height: 2em;
color: #fff;
text-align: center;
font-size: 2rem;
transform: rotateY(180deg);
}
//No JS
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.