首页 前端知识 css动画效果代码淡入淡出折叠展开点击悬浮

css动画效果代码淡入淡出折叠展开点击悬浮

2024-06-06 00:06:46 前端知识 前端哥 934 770 我要收藏

css动画效果代码淡入淡出折叠展开点击悬浮

淡入

.coup-anim {
	width: -webkit-fill-available;
	bottom: 0;
	position: fixed;
	border-radius: 20upx;
	margin-bottom: 0;
	margin: 20upx 100upx;
	background-color: #fff;
	height:900upx;
	/* 淡入 */
	animation: fadeIn 0.4s .1s ease both;
}

@keyframes fadeIn {
 0% {
  opacity: 0;
  transform: translateY(400upx)
 }

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

请添加图片描述
淡出

.coup-anim {
		width: -webkit-fill-available;
		bottom: 0;
		position: fixed;
		border-radius: 20upx;
		margin-bottom: 0;
		margin: 20upx 100upx;
		background-color: #fff;
		height:900upx;
		
		animation: fadeIn 0.4s .1s ease both;
	}
	
	@keyframes fadeIn {
	 0% {
	  opacity: 1;
	  transform: translateY(0)
	 }
	
	 100% {
	  opacity: 0;
	  transform: translateY(calc(100% + 20upx))
	 }
	}

请添加图片描述
按钮点击css

.button {
	margin: 100upx;
	background-color: #e7ad8e;
	color: #900b09;
	opacity: 0.9;
}
.active {
	opacity: 1;
	transform: all .3s;
}

请添加图片描述
手风琴折叠

<template>
	<view>
		<view class="item" :class="item.class" v-for="item in list" :key="item.content">{{item.content}}</view>
		<button @click="test">测试</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[
					{content:'item1'},
					{content:'item2'},
					{content:'item3'},
					{content:'item4'},
					{content:'item5'},
					{content:'item6'}
				]
			}
		},
		methods: {
			test() {
				this.list = [
					{content:'item1'},
					{content:'item2'},
					{content:'item3'},
					{content:'item4'},
					{content:'item5'},
					{content:'item6'}
				]
				let time = 300
				for(let index in this.list) {
					time = (time + 30)
					setTimeout(() => {
						// $set新增属性响应式更新模板
						this.$set(this.list[this.list.length-index-1],'class','rotate')
						// this.list[index].class = 'rotate'
					},time)
				}
			}
		},
		onLoad() {
			
		}
	}
</script>

<style>
	page{
		background-color: #eee;
	}
	/* 折叠淡出 */
.item {
	padding: 15rpx;
	border-radius: 10rpx;
	margin: 20rpx;
	background-color: #fff;
	/* animation: fadeIn 0.4s .1s ease both; */
}

.rotate {
	animation: fadeIn 0.4s .1s ease both;
}

@keyframes fadeIn {
 0% {
  opacity: 1;
  transform: translateY(0)
 }

 100% {
  opacity: 0;
   transform: translateY(-100%)
 }
}
</style>

请添加图片描述
手风琴展开

<template>
	<view>
		<view class="item" :class="item.class" v-for="item in list" :key="item.content">{{item.content}}</view>
		<button style="position: fixed;bottom: 0;" @click="test">测试</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[
					{content:'item1'},
					{content:'item2'},
					{content:'item3'},
					{content:'item4'},
					{content:'item5'},
					{content:'item6'}
				]
			}
		},
		methods: {
			test() {
				this.list = [
					{content:'item1'},
					{content:'item2'},
					{content:'item3'},
					{content:'item4'},
					{content:'item5'},
					{content:'item6'}
				]
				let time = 300
				for(let index in this.list) {
					time = (time + 30)
					setTimeout(() => {
						// $set新增属性响应式更新模板
						this.$set(this.list[index],'class','rotate')
						// this.list[index].class = 'rotate'
					},time)
				}
			}
		},
		onLoad() {
			
		}
	}
</script>

<style>
	page{
		background-color: #eee;
	}
	/* 折叠淡出 */
.item {
	padding: 15rpx;
	border-radius: 10rpx;
	margin: 20rpx;
	opacity: 0;
	transform: translateY(-100%);
	background-color: #fff;
	/* animation: fadeIn 0.4s .1s ease both; */
}

.rotate {
	animation: fadeIn 0.4s .1s ease both;
}

@keyframes fadeIn {
 0% {
	  opacity: 0;
	   transform: translateY(-100%)
 }

 100% {
	 opacity: 1;
	 transform: translateY(0)
 }
}
</style>

请添加图片描述

转载请注明出处或者链接地址:https://www.qianduange.cn//article/10929.html
标签
评论
发布的文章

基于Vue2的ofd文件预览

2024-06-10 11:06:28

网页快速置灰效果

2024-06-10 11:06:17

HTML5 CSS——Day6

2024-06-10 11:06:11

HTML5 CSS3面试题整理

2024-05-05 22:05:21

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!