赞
踩
所以,我的CSS在3秒后将div移动到-40px.执行此操作后,div将移回其原始位置.这是代码:
#jsAlert { width: 100%; height: 40px; position: absolute; left: 0px; top: 0px; background-color: rgba(0, 0, 0, 0.6); animation:mymove 3s; animation-delay: 3s; /*Safari and Chrome*/ -webkit-animation: mymove 2s; -webkit-animation-delay: 2s; } @keyframes mymove { from {top: 0px;} to {top: -40px;} } @-webkit-keyframes mymove /*Safari and Chrome*/ { from {top: 0px;} to {top: -40px;} }
如何防止div返回其原始位置?
您需要使用animation-fill-mode
值设置为forwards
来自Mozilla开发者网络:
目标将保留由执行期间遇到的最后一个关键帧设置的计算值.遇到的最后一个关键取决于价值
animation-direction
和animation-iteration-count
Demo
本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/blog/CSS/detail/6269赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。