找到 1575 篇文章 关于 CSS
133 次查看
使用 animation-fill-mode 属性,并将其值设置为 both,即可双向扩展动画属性。示例实时演示 div { width: 150px; height: 200px; position: relative; background: red; animation-name: myanim; animation-duration: 2s; animation-fill-mode: both; } @keyframes myanim { from {left: 0px; background-color: green;} to {left: 200px; background-color: blue;} }
66 次查看
要使用 CSS 设置动画的填充模式,请使用 animation-fill-mode 属性。它具有 forwards、backward、both(两个方向)等值。您可以尝试运行以下代码来设置动画的填充模式;示例实时演示 div { width: 150px; height: 200px; position: relative; background: red; animation-name: myanim; animation-duration: 2s; animation-fill-mode: forwards; } @keyframes myanim { from {left: 0px; background-color: green;} to {left: 200px; background-color: blue;} }
269 次查看
使用 animation-timing-function 属性,并将其值设置为 ease-in-out,即可使用 CSS 设置动画的缓慢开始和结束:示例实时演示 div { width: 150px; height: 200px; position: relative; background-color: #808000; animation-name: myanim; animation-duration: 2s; animation-direction: alternate-reverse; animation-iteration-count: 3; } @keyframes myanim { from {left: 100px;} to {left: 200px;} } #demo {animation-timing-function: ease-out;} ease-in-out 效果
121 次查看
使用 animation-timing-function 设置动画的速度曲线。您可以尝试运行以下代码来设置 ease 和 ease-in 动画效果:示例实时演示 div { width: 150px; height: 200px; position: relative; background-color: yellow; animation-name: myanim; animation-duration: 2s; animation-direction: alternate-reverse; animation-iteration-count: 3; } @keyframes myanim { from {left: 100px;} to {left: 200px;} } #demo1 {animation-timing-function: ease;} #demo2 {animation-timing-function: ease-in;} ease 效果 ease-in 效果
1K+ 次查看
使用 animation-timing-function 属性,并将其值设置为 ease,即可使用 CSS 设置动画的缓慢开始,然后加速,最后缓慢结束示例实时演示 div { width: 150px; height: 200px; position: relative; background-color: yellow; animation-name: myanim; animation-duration: 2s; animation-direction: alternate-reverse; animation-iteration-count: 3; } @keyframes myanim { from {left: 100px;} to {left: 200px;} } #demo1 {animation-timing-function: ease;} ease 效果
2K+ 次浏览
使用 animation-direction 属性可以使动画先反向运行,然后再正向运行。该属性与 alternate-reverse 动画值一起使用以实现此目的。示例在线演示 div { width: 150px; height: 200px; position: relative; background-color: yellow; animation-name: myanim; animation-duration: 2s; animation-direction: alternate-reverse; animation-iteration-count: 3; } @keyframes myanim { 0% {background-color:green; left:0px; top:0px;} 50% {background-color:maroon; left:100px; top:100px;} 100% {background-color:gray; left:0px; top:0px;} }