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>
相关推荐
anOnion15 小时前
构建无障碍组件之Menu Button pattern
前端·html·交互设计
用户479492835691515 小时前
claude Fable用不了?把Gpt 5.5pro接到你的claude code里
前端·后端
zhangxingchao18 小时前
Kotlin常用的Flow 操作符整理
前端
IT_陈寒20 小时前
React的useState居然还有这种坑?我差点删库跑路
前端·人工智能·后端
Pedantic21 小时前
SwiftUI 手势笔记
前端·后端
橙子家21 小时前
浏览器缓存之【结构化数据库与缓存】: IndexedDB、Cache storage 和 Storage buckets
前端
user205855615181321 小时前
X6 中边悬浮置顶,规避 `mouseleave` 事件丢失问题
前端
李明卫杭州21 小时前
CSS aspect-ratio 属性完全指南
前端
Pedantic1 天前
SwiftUI 手势层级(Gesture Hierarchy)详解
前端