123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <style>
- *{
- margin: 0;
- padding: 0;
- }
- .box1{
- width: 800px;
- height: 800px;
- background-color: silver;
- overflow: hidden;
- margin-left: 0;
- }
- .box1 div{
- width: 100px;
- height: 100px;
- margin-bottom: 100px;
- margin-left: 10px;
- }
- .box2{
- background-color: #bfa;
- /* 设置box2的动画 */
- /* animation-name:要对当前元素生效的关键帧的名字 */
- /* animation-name: test; */
- /* animation-duration:动画的执行时间 */
- /* animation-duration: 2s; */
- /* animation-delay:动画的延时 */
- /* animation-delay: 2s; */
- /* animation-timing-function: ease-in-out; */
- /*
- animation-iteration-count:动画执行的次数
- 可选值:
- 次数
- infinite 无限执行
- */
- /* animation-iteration-count: 2; */
- /*
- animation-direction:指定动画运行的方向
- 可选值:
- normal:默认值,从from向to,每次都是这样
- reverse:从to向from运行,每次都是这样
- alternate:从from向to,重复执行动画时反向执行
- alternate-reverse:从to向from运行,重复执行动画时反向执行
- */
- /* animation-direction: normal;
- animation-direction: reverse;
- animation-direction: alternate;
- animation-direction: alternate-reverse; */
- /*
- animation-play-state:设置动画的执行状态
- 可选值:
- running:默认值,动画执行
- paused:动画暂停
- */
- /* animation-play-state: paused; */
- /*
- animation-fill-mode:动画的填充模式
- 可选值:
- none:默认值,动画执行完毕,元素回到原来的位置
- forwards:动画执行完毕,元素会停止在动画结束的位置
- backwards:动画延时等待时,元素就会处于开始位置
- both:结合了forwards和backwards
- */
- /* animation-fill-mode:both; */
- /*
- animation:简写属性,第一个时间表示动画的持续时间,第二个时间表示延迟时间,
- 其他没有顺序要求
- */
- animation: test 2s 3 1s alternate;
- }
- /* .box1:hover div{
- animation-play-state: paused
- } */
- /*
- 动画
- 动画和过渡类似,都是可以实现一些动态的效果,
- 不同的是过渡需要在某个属性发生变化时才会触发
- 动画可以自动触发动态效果
-
- 设置动画效果,必须先要设置一个关键帧,关键帧设置了动画执行的每一个步骤
- */
- @keyframes test{
- /* from 表示动画的开始位置,也可以使用0% */
- from{
- margin-left: 0;
- background-color: orange;
- }
- /* to 表示动画的结束位置,也可以使用100% */
- to{
- margin-left: 700px;
- background-color: red;
- }
- }
- </style>
- </head>
- <body>
-
- <div class="box1">
- <div class="box2"></div>
- <!-- <div class="box3"></div> -->
- </div>
- </body>
- </html>
|