Answer the question
In order to leave comments, you need to log in
How do you make a hover sprite?
Here we admit there is a button, and in it an icon.
<button>
<i class="icon icon__chat"></i>
<span>Button</span>
</button>
Answer the question
In order to leave comments, you need to log in
Let's say we have a sprite 50px high and 25px wide (2 icons, one above the other).
First we set the icon, and on hover, offset by 25px (or -25px)
.icon__chat{
background: url('img/sprite.png');
background-size: 100%;
width: 25px;
height: 25px;
}
.icon__chat:hover{
background-position: 0 25px;
}
button:hover > .icon__chat {
background-position: 0 25px;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question