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>
相关推荐
老前端的功夫15 分钟前
TypeScript 类型守卫:从编译原理到高级模式
前端·javascript·架构·typescript
前端 贾公子22 分钟前
[uniapp][swtich开关]阻止切换状态(类似阻止事件冒泡)
uni-app
未来之窗软件服务26 分钟前
幽冥大陆(七十二) 东方仙盟-在线IP归属地自己封装—东方仙盟练气期
前端·javascript·tcp/ip·仙盟创梦ide·东方仙盟·阿雪技术观
QT 小鲜肉40 分钟前
【Linux命令大全】001.文件管理之mc命令(实操篇)
linux·运维·服务器·前端·笔记
土豆_potato1 小时前
AI深度思考到底开不开
前端·aigc
ohyeah1 小时前
React 中的跨层级通信:使用 Context 实现主题切换功能
前端·react.js
winfredzhang1 小时前
打造专属桌面时钟:纯HTML实现的全功能动态时钟
前端·html·农历·生肖·周次
哥本哈士奇1 小时前
使用Gradio构建AI前端 - RAG的QA模块
前端·人工智能·状态模式
扶我起来还能学_2 小时前
Vue3 proxy 数据响应式的简单实现
前端·javascript·vue
Dragon Wu2 小时前
前端项目架构 项目格式化规范篇
前端·javascript·react.js·前端框架