<div class="play-pause"></div>
html, body {
height: 100%;
margin: 0;
background: #222;
}
body {
font-size: 100px;
display: flex;
align-items: center;
justify-content: center;
}
.play-pause {
/* This must match the background color behind the button */
color: #222;
/* This is the color of the button */
background-color: #f06;
width: 1em; height: 1em;
position: relative;
cursor: pointer;
overflow: hidden;
/* Draw the 2 pause bars */
background-image: linear-gradient(to right,
transparent 40%,
currentColor 40%,
currentColor 60%,
transparent 0);
background-position: center;
background-repeat: no-repeat;
background-size: 100% 100%;
/* Hide the central part between the 2 bars */
transition: background-size .3s;
}
.play-pause.paused {
background-size: 0 100%;
}
.play-pause::before,
.play-pause::after {
content: "";
position: absolute;
top: 0;
height: 100%;
width: 100%;
background: currentColor;
/* Before and after are skewed at 90deg to be invisible */
transform: skew(90deg);
transform-origin: top left;
/* And transitioned to the right angle to transform the square into a
triangle */
transition: transform .3s;
}
.play-pause::after {
transform-origin: bottom left;
}
.play-pause.paused::before {
transform: skew(64deg);
}
.play-pause.paused::after {
transform: skew(117deg);
}
document.querySelector(".play-pause").addEventListener("click", function() {
this.classList.toggle("paused");
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.