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>
相关推荐
lecepin2 分钟前
AI Coding 资讯 2025-11-05
前端·javascript
excel5 分钟前
Vue 模板解析器 parserOptions 深度解析
前端
前端小咸鱼一条10 分钟前
17.React获取DOM的方式
前端·javascript·react.js
excel12 分钟前
Vue 编译核心中的运行时辅助函数注册机制详解
前端
excel12 分钟前
🌿 深度解析 Vue DOM 编译器模块源码:compile 与 parse 的构建逻辑
前端
excel14 分钟前
深度解析 Vue 编译器中的 transformShow:v-show 指令的编译原理
前端
excel14 分钟前
深度解析:decodeHtmlBrowser —— 浏览器端 HTML 解码函数设计
前端
excel15 分钟前
深度解析:Vue 模板编译器中的 transformVText 实现原理
前端
excel15 分钟前
深度解析:isValidHTMLNesting —— HTML 嵌套合法性验证的设计与实现
前端
冴羽16 分钟前
看了下昨日泄露的苹果 App Store 源码……
前端·javascript·svelte