Would you like to set up a cool basic transition for your buttons when the cursor is over them?
- Create your HTML button. We have chosen the smile face character but you can use whatever you want (I normaly use Font Awesome).
- Define your CSS transition. In our case we want a period of 0.5 seconds every time our CSS changes and a transition effect with a slow start and end (ease-in-out).
transition: all 0.5s ease-in-out;
Our CSS will change if the mouse is over the button.
i { box-shadow: 0 0 0 75px #E94F37 inset; color: white; } i:hover { box-shadow: 0 0 0 4px #E94F37 inset; color:#E94F37; }
We are filling up the element with an inner shadow (inset) and changing the font color.
Here a real example:
HTML CSS<i>☺</i>
<i>☺</i>
<i>☺</i>
i {
text-align: center;
position: relative;
display: inline-block;
margin: 10px;
cursor: pointer;
width: 140px;
height: 140px;
line-height: 140px;
font-size: 70px;
color: white;
border-radius: 50%;
transition: all 0.5s ease-in-out;
box-shadow: 0 0 0 75px #E94F37 inset;
}
i:hover {
box-shadow: 0 0 0 4px #E94F37 inset;
color:#E94F37;
}
i:nth-child(even) {
box-shadow: 0 0 0 75px #44BBA4 inset;
}
i:nth-child(even):hover {
box-shadow: 0 0 0 4px #44BBA4 inset;
color:#44BBA4;
}