<div class="center">
<div id="control">
<div class="border"></div>
<div class="play"></div>
</div>
</div>
body {
background: #333;
}
div.center{
position:absolute;
top:50%;
left:50%;
transform:translate(-50%, -50%);
}
#control {
position: absolute;
bottom: 10px;
width: 20px;
height: 20px;
right: 10px;
cursor: pointer;
.border {
width: 100%;
height: 100%;
border: 1px solid #41fff5;
border-radius: 20px;
}
&.is--playing .border {
border-top: none;
border-bottom: none;
animation: spin 1.5s ease-in-out infinite;
}
.play {
position: absolute;
top: 6px;
left: 9px;
box-sizing: border-box;
height: 7px;
width: 5px;
border-color: transparent transparent transparent #41fff5;
transition: 100ms all ease;
will-change: border-width;
cursor: pointer;
// play state
border-style: solid;
border-width: 5px 0 5px 5px;
}
&.is--playing .play {
border-style: double;
border-width: 0px 0 0px 6px;
transform: translate(-1px, 1px);
}
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
View Compiled
var playButton = document.getElementById('control');
playButton.addEventListener('click', e => {
e.preventDefault();
playButton.classList.toggle('is--playing');
});
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.