uniapp实现图片上下浮动效果

实现效果

图片以Y轴进行上下浮动

实现代码
html 复制代码
<template>
	<view class="header">
	
		<view class="image-center">
			<image src="../../static/image/index_center.png" class="centers"></image>
		</view>
	</view>

</template>

<script setup>

</script>

<style lang="scss" scoped>
	.header {

		.image-center {
			width: 600rpx;
			height: 400rpx;

			.centers {
				width: 100%;
				height: 100%;
				animation: float 4s ease-in-out infinite;
				/* 控制动画的速度、时间、迭代次数等 */
			}

			@keyframes float {
				0% {
					transform: translateY(0);
				}

				50% {
					transform: translateY(-40rpx);
				}

				100% {
					transform: translateY(0);
				}
			}
		}


	}
</style>
相关推荐
skywalk816315 分钟前
Kotti Next的tinyfrontend前端模仿Kotti 首页布局还是不太好看,感觉比Kotti差一点
前端
RopenYuan2 小时前
FastAPI -API Router的应用
前端·网络·python
走粥3 小时前
clsx和twMerge解决CSS类名冲突问题
前端·css
Purgatory0013 小时前
layui select重新渲染
前端·layui
weixin199701080163 小时前
《中国供应商商品详情页前端性能优化实战》
前端·性能优化
赵孝正5 小时前
学习的本质是一个工程闭环:从模仿到内化的四阶段方法论(附风电实战案例)
前端·数据库·学习
Panzer_Jack7 小时前
easy-live2d v0.4.0 — 全面进化的 Live2D Web 开发体验
前端
软弹7 小时前
输入URL之后,都发生了什么
前端