animation与transition

先说说transition

transition有四个基本概念,只要记牢这几个概念,以后碰到transition就不会犯晕了

transition: [属性名] [持续时间] [速度曲线] [延迟时间];

//高度属性的值改变时,延迟 0.5 秒后以 ease 曲线进行过渡,持续2秒:
transition: height 2s ease .5s;
//监听所有属性
transition: all 2s ease .5s;

transform

transform: [转换函数];
transform接受一个转换函数,每个转换函数都会有不同的效果

//当前元素往上移动 10 像素,往右移动 10 像素
transform: translate(-10px, 10px)

指定多个转换效果

//向右下角移动 10 像素并顺时针旋转10度
transform: translate(10px, 10px) rotate(10deg)

transition + transform

//这种写法可以给transform指定一个过渡
transition: transform 2s ease .5s;
//当鼠标移动到div上,div旋转180度
.child {
	width: 100px;
	height: 100px;
	background-color: blue;
	transition: all 0.3s ease-in-out;
}

.child:hover {
	transform: rotate(180deg);
}

animation

<div class="animation">
	动画
</div>
<div class="gradually">
	渐变
</div>
.animation{
	width: 100px;
	height: 100px;
	animation:myfirst 5s;
}
@keyframes myfirst{
	from{background:red}
	to{background:green}
}
.gradually{
	width: 100px;
	height: 100px;
	animation: mysecond 5s;
}
@keyframes mysecond{
	10%{background:red};
	25%{background:green};
	75%{background:red};
	100%{background: pink};
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值