经典卡片翻转动画实现

本文介绍了如何在页面布局中实现经典卡片翻转动画,包括卡片翻转动画的重置和增加卡片登场的keyframes动画。同时,还提及了烟花动画的实现,提供了完整的代码示例。
摘要由CSDN通过智能技术生成

页面布局的实现

在这里插入图片描述
最终布局如图所示
在这里插入图片描述
这是分布的大致格式

<template>
    <div class="flap-card-wrapper" v-show="flapCardVisible">
        <div class="flap-card-bg">
            <div class="flap-card" v-for="(item,index) in flapCardList" :key="index" :style="{
      zIndex:item.zIndex}">
                <div class="flap-card-circle">
                    <div class="flap-card-semi-circle flap-card-semi-circle-left"
                         :style="semiCircleStyle(item,'left')"></div>
                    <div class="flap-card-semi-circle flap-card-semi-circle-right"
                         :style="semiCircleStyle(item,'right')"></div>
                </div>
            </div>
        </div>
        <div class="close-btn-wrapper" @click="close">
            <span class="icon-close"  ></span>
        </div>
    </div>
</template>

<script>
    import {
    storeHomeMixin} from "../../utils/mixin";
    import {
     flapCardList } from "../../utils/store";

    export default {
    
        name: "FlapCard",
        mixins:[storeHomeMixin],
        data(){
    
            return{
    
                flapCardList
            }
        },
        methods:{
    
            semiCircleStyle(item,dir){
    
                return{
    
                    backgroundColor:`rgb(${
      item.r},${
      item.g},${
      item.b})`,
                    backgroundSize:item.backgroundSize,
                    backgroundImage:dir === 'left'? item.imgLeft:item.imgRight
                }
            },
            close(){
    
                console.log("hah");
                this.setFlapCardVisible(false);
            }
        }
    }
</script>

<style scoped lang="scss">
    @import "./../../assets/styles/global";
    .flap-card-wrapper{
    
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        z-index: 1000;
        width: 100%;
        height: 100%;
        background-color: rgba(0,0,0,.6);
        @include center;
        .flap-card-bg{
    
            position: relative;
            width: px2rem(64);
            height: px2rem(64);
            border-radius: px2rem(5);
            background: white;
            .flap-card{
    
                width: px2rem(48);
                height: px2rem(48);
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                margin: auto;

                .flap-card-circle{
    
                    display: flex;
                    width: 100%;
                    height: 100%;

                    .flap-card-semi-circle{
    
                        flex: 0 0 50%;
                        width: 50%;
                        height: 100%;
                        background-repeat: no-repeat;
                    }
                    .flap-card-semi-circle-left{
    
                        border-radius: px2rem(24) 0 0 px2rem(24);
                        background-position: center right;
                    }
                    .flap-card-semi-circle-right{
    
                        border-radius:0 px2rem(24) px2rem(24) 0;
                        background-position: center left;
                    }
                }
            }
        }
        .close-btn-wrapper{
    
            position: absolute;
            left: 0;
            bottom: px2rem(30);
            z-index:1100;
            width: 100%;
            @include center;
            .icon-close{
    
                width: px2rem(45);
                height: px2rem(45);
                font-size: 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值