In my demo application, I have successfully created a Play and Pause icon. However, there is an additional requirement - I need to display the text PLAY and PAUSE when hovering.
Currently, I am encountering two issues:
- The icon jumps when hovering over the button
- The PLAY or PAUSE text is not centered (it appears slightly below)
- I also need to display different text depending on the state
To see the code, please visit: https://jsbin.com/qifigeruti/3/edit?html,css,js,output
.container {
padding: 8px;
border: 1px solid;
display: inline-block;
}
.text {
display: none;
}
.button {
border: 0;
background: transparent;
box-sizing: border-box;
width: 0;
height: 20px;
border-color: transparent transparent transparent #202020;
transition: 100ms all ease;
cursor: pointer;
border-style: solid;
border-width: 10px 0 10px 20px;
padding: 0
}
.button.paused {
border-style: double;
border-width: 0px 0 0px 20px;
}
.button:hover {
border-color: transparent transparent transparent #404040;
}
.button:hover span {
display: inline;
}
<div class="container">
<button class='button'>
<span class="text">Play</span>
</button>
</div>