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

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

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>


相关文章
|
26天前
|
缓存 前端开发
前端代码整洁与规范之CSS篇
【4月更文挑战第2天】 前端代码整洁与规范之CSS篇
43 4
|
1月前
|
前端开发 内存技术
CSS动画示例(上一篇是CSS过渡…)
CSS动画示例(上一篇是CSS过渡…)
23 1
|
21小时前
|
XML 前端开发 JavaScript
CSS中动画、过渡、定位、浮动的作用
CSS中动画、过渡、定位、浮动的作用
|
7天前
|
前端开发 JavaScript 容器
JavaScript、CSS像素动画特效代码
此示例创建一个带有像素粒子的容器,每隔300毫秒就会动态添加一个新的像素粒子,然后通过CSS的关键帧动画(`@keyframes`)使它们产生上升和逐渐消失的动画效果。你可以根据需要修改像素粒子的颜色、大小、动画效果和创建速度。
8 0
|
15天前
|
编解码 前端开发 iOS开发
前端开发入门笔记(八)CSS3属性详解:动画详解+Flex布局图文详解+Web字体
前端开发入门笔记(八)CSS3属性详解:动画详解+Flex布局图文详解+Web字体
57 1
|
22天前
|
前端开发
css3动画
css3动画
21 0
|
26天前
|
前端开发
CSS动画知识点学习
【4月更文挑战第2天】CSS动画知识点学习
19 3
|
28天前
|
前端开发 UED
CSS——如何取消a链接点击时的背景颜色
CSS——如何取消a链接点击时的背景颜色
9 1
|
1月前
|
前端开发
当当网新用户注册界面——CSS代码
当当网新用户注册界面——CSS代码
9 0
|
1月前
|
前端开发
当当网首页——CSS代码
当当网首页——CSS代码
11 1