当您将鼠标悬停在图片上时,蓝色箭头会缓慢移动。当您从图像上删除光标时,白色箭头会急剧返回。如何使白色箭头缓慢返回?
@keyframes left_to_right {
from {margin-left: -15px;}
to {margin-left: 0; }
}
div .footer-text{
position: absolute;
top: 10%;
left: 3%;
height: 20px;
width: 85%;
}
div .footer-text:after{
content: '';
background: url('https://www.nsartmuseum.ru/images/test/arrow-after-3.png') no-repeat;
width: 130px;
height: 15px;
display: inline-block;
margin-left: 10px;
position: relative;
}
div:hover .footer-text:before{
content: '';
background: url('https://www.nsartmuseum.ru/images/test/arrow-before-3.png') no-repeat;
width: 130px;
height: 15px;
margin-right: 5px;
display: inline-block;
animation: left_to_right 0.4s ease;
}
div:hover .footer-text:after{
content: '';
background: none;
}
div .footer-text span{
position: relative;
top:-5px;
font-size: 12px;
color: #313B78;
display: inline-block;
}
<div>
<a href="" class='footer-text'>
<span>13 September</span>
</a>
</div>
很明显,有很多方法可以通过CSS动画来做到这一点,但是我在开发中从未使用过。
希望对您有帮助。
@keyframes left_to_right {
from {
margin-left: -15px;
}
to {
margin-left: 0;
}
}
div .footer-text {
position: absolute;
top: 10%;
left: 3%;
height: 20px;
width: 85%;
}
div .footer-text:after {
content: '';
background: url('https://www.nsartmuseum.ru/images/test/arrow-after-3.png') no-repeat;
width: 130px;
height: 15px;
display: inline-block;
margin-left: 10px;
position: relative;
animation: left_to_right 0.4s ease;
}
div:hover .footer-text:before {
content: '';
background: url('https://www.nsartmuseum.ru/images/test/arrow-before-3.png') no-repeat;
width: 130px;
height: 15px;
margin-right: 5px;
display: inline-block;
animation: left_to_right 0.4s ease;
}
div:hover .footer-text:after {
display: none;
}
div .footer-text span {
position: relative;
top: -5px;
font-size: 12px;
color: #313B78;
display: inline-block;
}
<div>
<a href="" class='footer-text'>
<span>13 September</span>
</a>
</div>