animation动画--跳动

给大家分享一个小案例,让静态的一行字与一个球变为动态跳动
第一个文字动画

<title></title>
		<style>
			.box{
				width: 600px;
				height: 150px;
				margin: auto;
				margin-top: 300px;
				background-color: deepskyblue;
			}
			.box p{
				display: inline-block;
				font-size: 50px;
				text-align: center;
				margin-left: 20px;
				animation: dong 2s infinite; /*设置动画效果,dong与后面的动画设置相连接 完整运动时间为两秒,一直循环*/
			}
			/*选择第二个p标签*/
			.box p:nth-of-type(2){
				animation-delay: 0.5s;
			}
			.box p:nth-of-type(3){
				animation-delay: 0.75s;
			}
			.box p:nth-of-type(4){
				animation-delay: 1s;
			}.box p:nth-of-type(5){
				animation-delay: 1.25s;
			}
			.box p:nth-of-type(6){
				animation-delay: 1.5s;
			}
			.box p:nth-of-type(7){
				animation-delay: 1.75s;
			}
			.box p:nth-of-type(8){
				animation-delay: 2s;
			}
			/*动画设置*/
			@keyframes dong{
				0%{}
				50%{transform: translateY(-50px)}
				100%{}
			}
		</style>
	</head>
	<body>
		<div>
			<div class="box">
				<p>正</p>
				<p>在</p>
				<p>加</p>
				<p>载</p>
				<p>中</p>
				<p>.</p>
				<p>.</p>
				<p>.</p>
			</div>
		</div>
	</body>

在这里插入图片描述
在这里插入图片描述
第二个小球跳动动画

<title></title>
		<style>
			.div{
				margin: 0 auto;
				width: 800px;
				height: 700px;
				margin-top: 100px;
			}
			.box1{
				width: 80px;
				height: 80px;
				border-radius: 50%;
				background-image: linear-gradient(blue,black);/*给小球添加一个颜色渐变*/
				margin-top: 500px;
				margin-left: 400px;
				animation:dong 2s infinite;
			}
			.box2{
				width: 80px;
				height: 10px;
				border-radius: 50%;
				background-color: cadetblue;
				margin-left: 400px;
			}
			@keyframes dong{
				0%{} 
				50%{ transform: translateY(-300px);}
				100%{}
			}
		</style>
	</head>
	<body>
		<div class="div">
			<div class="box1"></div>
			<div class="box2"></div>
		</div>	
	</body>

在这里插入图片描述
在这里插入图片描述

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值