Creates a fill animation on hover.
- Set a
color
andbackground
and use an appropriatetransition
to animate changes to the element. - Use the
:hover
pseudo-class to change thebackground
andcolor
of the element when the user hovers over it.
预览
HTML
<button class="animated-fill-button">Submit</button>
CSS
.animated-fill-button {
padding: 20px;
background: #fff;
color: #000;
border: 1px solid #000;
cursor: pointer;
transition: 0.3s all ease-in-out;
}
.animated-fill-button:hover {
background: #000;
color: #fff;
}
翻译自:https://www.30secondsofcode.org/css/s/button-hover-fill-animation