CSS3——CSS3动画(animation)及应用

动画(CSS3) animation

动画是CSS3中具有颠覆性的特征之一,可通过设置多个节点来精确控制一个或一组动画,常用来实现复杂的动画效果。

语法格式:

animation:动画名称 花费时间 运动曲线  何时开始
  播放次数  是否反方向;

关于几个值,除了名字,动画时间,延时有严格顺序要求其它随意r

@keyframes 动画名称 {
   
  from{
    开始位置 }  0%
  to{
     结束  }  100%
}
animation-iteration-count:infinite;  无限循环播放    默认是1次
animation-direction: alternate   动画应该轮流反向播放    默认是 normal
animation-play-state:paused;   暂停动画"

案例1:太阳系的运作

在这里插入图片描述
代码:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>宇宙动画</title>
        	<style type="text/css">
        		* {
     
        			margin: 0;
        			padding: 0;
        		}
        		html,body {
     
                    /*margin: 50px;*/
        			 width: 100%;
        			 height: 100%;
        			 background: url(img/bg.jpg) no-repeat;
        			 background-size: cover;
        			 position: relative;
        		}
        		.box {
     
        			width: 600px;
        			height: 600px;
        			border: 1px solid #ccc;
        			border-radius: 50%;
        			position: absolute; 
        			left: 50%;
        			margin-left: -300px;
        			top: 50%;
        			margin-top: -300px;
        		}

        		.sun {
     
        			 position: absolute;
        			 width: 50px;
        			 height: 50px;
        			 background-color: orange;
        			 border-radius: 50%;
        			 margin-left: -25px;
        			 left: 50%;
        			 margin-top: -25px;
        			 top: 50%;
                     
        			 box-shadow: 0px 0px 100px orange; /*周围日光的效果*/
        		}

        		.lin1 {
     
        			 width: 100px;
        			 height: 100px;
        			 border: 1px solid #ccc;
        			 border-radius: 50%;
        			 margin-left: -50px;
        			 margin-top: -50px;
        			 animation: rotate 10s linear infinite;
        		}

        		.lin1:after {
     
        			 content: "";
        			 width: 20px;
        			 height: 20px;
        			 display: block;
        			 border-radius: 50%;
        			 background-color: orange;
        			 position: absolute;
        			 left: -2px;
        			 top: 10px;
        		}

        		.public {
     
        			 position: absolute;
        			 left: 50%;
        			 top: 50%;
        		}




        		@keyframes rotate {
     
        			 from {
     
        			    transform: rotateZ(0deg);
                        /*transform: rotateX(0deg);*/
        			 }

        			 to {
     
        			 	 transform: rotateZ(360deg);
                          /*transform: rotateX(360deg);*/
        			 }
        		}

        		.lin2 {
     
        			 width: 150px;
        			 height: 150px;
        			 border: 1px solid #ccc;
        			 border-radius: 50%;
        			 margin-left: -75px;
        			 margin-top: -75px;

        			
                      animation: rotate /*rotateX*/ 5s linear infinite;
        		}
        		.lin2:after {
     
        			content: "";
        			width: 10px;
        			height: 10px;
        			background-color
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我心向阳iu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值