我有一个基本的HTML和CSS按钮,当鼠标悬停在上面时会显示文本。我想要修正动画效果,因为目前不是很正确。
当鼠标移开时,动画会使按钮的大小急剧减小。所以也许可以添加一个过渡效果来完成它?
希望我表达的足够清晰了!
.home-button {
line-height: 100%;
padding: 5px 40px 5px 5px;
font-family: Arial;
font-size: 12px;
position: relative;
}
.home-button span {
position: absolute;
top: 20px;
opacity: 0;
font-weight: 600;
color: #454b54;
}
.home-button:hover {
animation-name: enlarge;
animation-duration: 1s;
animation-fill-mode: forwards;
}
.home-button:hover span {
animation-name: appear;
animation-duration: 1.5s;
animation-fill-mode: forwards;
}
.home-button::before {
margin-right: 5px;
background-image: url(https://mcusercontent.com/ec104f3d77537e1962ab6441c/images/d7bb4928-a156-4682-9677-d0d5b47c3a21.png);
background-size: 40px 40px;
display: inline-block;
width: 40px;
height: 40px;
border-radius: 100%;
content: "";
}
.home-complement-button {
background-color: #fff;
border-radius: 100px;
box-shadow: 0 4px 8px #dadce0;
transition: 0.3s;
}
.home-complement-button:focus {
background-color: #e8f0fb !important;
}
@keyframes appear {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes enlarge {
from {
padding-right: 40px;
}
to {
padding-right: 50px;
}
}
<div style="display:flex;user-select:none"><a class="home-button home-complement-button" href="https://esims.one/" style="-webkit-tap-highlight-color:rgba(0,0,0,0);text-decoration:none"><span>Home</span></a></div>