css @keyframes配合animation 简单动画效果

1.animation

animation 属性是一个简写属性,用于设置六个动画属性:
语法:

animation: name duration timing-function delay iteration-count direction

属性可选值描述
animation-name规定需要绑定到选择器的 keyframe 名称
animation-duration规定完成动画所花费的时间
animation-timing-functionlinear | ease | ease-in | ease-out | ease-in-out规定动画的速度曲线
animation-delay规定在动画开始之前的延迟
animation-iteration-count规定动画应该播放的次数
animation-directionnormal | reverse | alternate | alternate-reverse规定是否应该轮流反向播放动画

2.keyframes 关键帧

@keyframes animationname { 
	keyframes-selector {
		css-styles;
	}
}
<div class="box"></div>

渐隐渐现效果:

.box {
	width: 100px;
	height: 100px;
	border-radius: 50%;
	background-color: pink;
	animation: shadow 1s linear infinite alternate;
}

@keyframes shadow {
	0% {
		opacity:0;
	}
	100% {
		opacity: 1;
	}
}

移动效果:
.arrow {
	display: block;
	width: 20px;
	height: 20px;
	position: absolute;
	bottom: 25px;
	left: 50%;
	margin-left: -11px;
	border: 3px solid transparent;
	border-top: 3px solid #000;
	border-left: 3px solid #000;
	z-index: 99;
	opacity: .8;
	transform: rotate(45deg);
	animation: arrow 1.5s ease-in-out infinite;
}
          
@keyframes arrow {
	0% {
		opacity:0;
		transform:translate(0, 0px) rotate(45deg)
	}
	50% {
		opacity:1;
		transform:translate(0, -5px) rotate(45deg)
	}
	00% {
		opacity:0;
		transform:translate(0, -10px) rotate(45deg)
	}
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值