<div class="button" onclick="toggleClass()">
<div id="signifier" class="add"></div>
</div>
html, body {
height: 100%;
}
body {
background: linear-gradient(#094481, #0D58A6);
}
.button {
position: relative;
height: 50px;
width: 50px;
background-color: #f50;
border-radius: 50%;
padding-top: 13px;
margin: auto;
box-sizing: border-box;
}
.add {
position: absolute;
margin: auto;
height: 20px;
width: 4px;
background-color: #fff;
top: 14px;
left: 23px;
}
.add:before, .add:after {
position: absolute;
top: 8px;
left: -8px;
content: ' ';
height: 4px;
width: 20px;
background-color: #fff;
}
.play {
height: 0;
width: 0;
margin-left: 15px;
border-left: 25px solid #fff;
border-top: 13px solid transparent;
border-bottom: 13px solid transparent;
}
.pause {
height: 20px;
width: 20px;
border: none;
margin-left: 15px;
border-right: 5px solid white;
border-left: 5px solid white;
box-sizing: border-box;
}
let listToggle = 0
const classes = ['play', 'add', 'pause']
/* if you're actually writing a music player you'd make more complicated logic than this, but from here you can see how to toggle classes with javascript */
const toggleClass = () => {
const sig = document.getElementById('signifier')
sig.classList = classes[listToggle++ % classes.length]
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.