【发布时间】:2015-02-18 18:57:49
【问题描述】:
我正在尝试仅使用 CSS 解决方案在悬停时实现此按钮动画:
我已经成功找到了一种使用 css keyframe 的方法,但现在我面临一些意想不到的慢动作效果,现在我只是在左上角进行实验,这就是我所做的到目前为止:
HTML
<a href=""><div class="borderTop"></div></a>
CSS
a {
width: 150px;
height: 50px;
border: 2px solid;
margin: 0 auto;
margin-top: 20%;
display: block;
}
a:hover .borderTop {
width: 10px;
height: 2px;
border-top: 2px solid;
position: relative;
top: -2px;
-webkit-animation: topTheleft 2s alternate;
animation: topTheleft 2s alternate;
}
.borderTop {
width: 10px;
height: 2px;
border-top: 2px solid;
position: relative;
top: -2px;
left: 50px;
}
@-webkit-keyframes topTheleft {
0% { left: -2px; }
50% { left: -30px; }
100% { left: -70px; display: none; }
}
@-o-keyframes topTheleft {
0% { left: -2px; }
50% { left: -30px; }
100% { left: -70px; display: none; }
}
@-moz-keyframes topTheleft {
0% { left: -2px; }
50% { left: -30px; }
100% { left: -70px; display: none; }
}
@keyframes topTheleft {
0% { left: -2px; }
50% { left: -30px; }
100% { left: -70px; display: none; }
}
任何关于如何避免动画中间的慢动作的帮助将不胜感激,提前谢谢你
编辑,有没有办法在到达left: -70px 时隐藏线路,并且过渡效果不是ansta-hide,也欢迎任何其他解决方案
【问题讨论】:
标签: html css css-animations keyframe