transition ,animation学习

.tra {
				margin: 20px auto;
				width: 100px;
				height: 200px;
				background-color: #99CCFF;
				transition: all 1s;
				color: #AA00FF;
				font-size: 30px;
			}

			/* .tra:hover{
			    transform: translateX(100px);
			} */
			.trans {
				transform: translateX(100px);
			}
			button{
			    border-style: none;
				outline-style: none;
				width: 100px;
				height: 50px;
				background-color: #AAAAFF;
				color: white;
				font-size: 24px;
				border-radius: 5px;
				
			}

			.animation {
				width: 50px;
				height: 100px;
				border-radius: 10px;
				background-color: #FFC0CB;
				animation: gup 10s ease forwards;
				color: white;
				font-size: 18px;
				text-align: center;
			}
			.animation :after{
				width: 50px;
				height: 100px;
				border-radius: 10px;
				background-color: #FFC0CB;
				animation: gup 10s ease forwards;
				color: white;
				font-size: 18px;
				text-align: center;
				content: "";
			}

			@keyframes gup {
				0% {
					obackground-color: #55557f;
					content: "准备ing";
				}
                  
				25% {
					obackground-color: #aaaaff;
					transform:translate(100px,100px);
					content: "我要起飞啦";
				}
				50% {
					background-color: #55aa00;
					transform:translateX(200px);
					content: "飞啊啊啊啊";
				}
				75% {
					background-color: #ffaaff;
					transform:translate(300px, 100px);
					content: "aaa掉了掉了";
				}
				100% {
					background-color: #aa00ff;
					transform:translateX(400px);
					content: "演示失败,再见";
				}
		    }
			 #content span{
			        display: none
			    }
			    #content:after{
			        content: '当月';
			    }
		</style>
	</head>
	<body>
		<div class="tra">是谁的小眼睛看我</div>
		<button style="display:block;margin: 0 auto;"> 点我</button>

		<div class="animation">
			<span> </span>
		</div>
		
		
		<!-- <div id='content'>
		    <span>今天</span>
		</div> -->
	</body>
	<script>
		var btn = document.querySelector("button");
		var le = document.querySelector(".tra");
		btn.onclick = function() {
			le.classList.add('trans')
		}
		btn.onmousemove = function() {
			le.classList.remove('trans')
		}
	</script>
  • transition使用注意点:
  1. 和transform配合使用
  2. 需要事件触发
  • animaition 使用注意点:
  1. 使用 关键帧:动画执行过程中,物体在某一位置上的特殊状态
    关键帧动画:使用连续的关键帧,控制物体连续的状态变化
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值