原生实现底部弹窗效果 h5 小程序

news/2024/7/9 23:50:36 标签: 小程序, vue, h5

 

<template>
  <div class="home">
    <div class="btn" @click="showPopup='show'">
        弹出底部蒙层
    </div>
    <div class="popup " catchtouchmove="true" :class="showPopup" >
        <div class="mask"></div>
        <div class="layer attr-content">
            <div class="close" @click="closePopup">关闭</div>
        </div>
    </div>
  </div>
</template>
<script>
export default{
    data(){
        return{
            showPopup:'none'
        }
    },
    methods:{
        closePopup(){
            this.showPopup = 'hide';
            setTimeout(() => {
                this.showPopup = 'none';
            }, 250);
        }
    }
}
</script>

 

<style lang="scss" scoped>
.btn{
    width:200px;
    height:50px;
    text-align: center;
    line-height: 50px;
    font-size:16px;
    position: fixed;
    left:50%;
    top:40%;
    transform: translateX(-50%);
    cursor: pointer;
}

.popup {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    overflow: hidden;
    &.show {
        display: block; 
    }   
    .close{
        width:100px;
        height:50px;
        font-size: 16px;
        line-height: 50px;
        text-align: center;
    }
    &.hide {
        .mask {
            animation: hidePopup 0.2s linear both;
        }
    
        .layer {
            animation: hideLayer 0.2s linear both;
        }
    }
    
    &.none {
        display: none;
    }
    
    .mask {
        position: fixed;
        top: 0;
        width: 100%;
        height: 100%;
        z-index: 1;
        background-color: rgba(0, 0, 0, 0.3);
        animation: showPopup 0.2s linear both;

    }
    .layer {
        display: flex;
        width: 100%; 
        flex-direction: column;
        min-height: 40vh;
        max-height: 1014rpx;
        position: fixed;
        z-index: 99;
        bottom: 0;
        border-radius: 10upx 10upx 0 0;
        background-color: #fff;
        animation: showLayer 0.2s linear both;
    }
}
@keyframes showPopup {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

@keyframes hidePopup {
    0% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

@keyframes showLayer {
    0% {
        transform: translateY(120%);
    }

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

@keyframes hideLayer {
    0% {
        transform: translateY(0);
    } 
    100% {
        transform: translateY(120%);     
    }
}
</style>


http://www.niftyadmin.cn/n/5213589.html

相关文章

无需外接显示器,直接使用windows安装树莓派系统并可远程桌面登录

准备工作: 1.安装树莓派官方烧录工具 raspberry pi imager 2.下载树莓派系统镜像(也可选择在线下载安装) 打开imager工具&#xff0c;选择需要安装包树莓派版本 点击"NEXT"&#xff0c;在弹出的选项中选择编辑设置。 设置登录名和密码&#xff0c;已经所连接的wif…

Docker简介与安装

Docker简介 1.什么是docker docker是解决了运行环境和配置问题的软件容器。是一种方便做持续集成并有助于整体发布的容器虚拟化技术。docker官网&#xff1a;http://www.docker.com 2.与传统虚拟技术的区别 传统虚拟机技术是虚拟出一套硬件后&#xff0c;在其上运行一个完整…

Kafka系列 - 生产者客户端架构以及3个重要参数

整体架构 整个生产者客户端由两个县城协调运行&#xff0c;这两个线程分别为主线程和Sender线程&#xff08;发送线程&#xff09;。 主线程中由KafkaProducer创建消息&#xff0c;然后通过可能的拦截器&#xff0c;序列化器和分区器之后缓存到消息累加器&#xff08;RecordAc…

续新的SSL证书

一、重新申请证书并下载证书&#xff1a; https://www.ename.net/ 二、IIS中在【服务器证书】中删除旧的证书&#xff0c;导入新的证书&#xff1b; 三、在站点的绑定选择新证书&#xff1b;

142.【Nginx负载均衡-01】

Nginx_基础篇 (一)、Nginx 简介1.背景介绍(1).http和三大邮局协议(2).反向代理与正向代理 2.常见服务器对比(1).公司介绍(2).lls 服务器(3).Tomcat 服务器(4).Apache 服务器(5).Lighttpd 服务器(6).其他的服务器 3.Nginx的优点(1).速度更快、并发更高(2).配置简单&#xff0c;扩…

代码随想录算法训练营第32天|122.买卖股票的最佳时机II 55. 跳跃游戏 45.跳跃游戏II

JAVA代码编写 122. 买卖股票的最佳时机 II 给你一个整数数组 prices &#xff0c;其中 prices[i] 表示某支股票第 i 天的价格。 在每一天&#xff0c;你可以决定是否购买和/或出售股票。你在任何时候 最多 只能持有 一股 股票。你也可以先购买&#xff0c;然后在 同一天 出售…

希尔伯特变换-matlab仿真

希尔伯特变换&#xff08;hilbert transform&#xff09;简介 在信号处理中我们常见的有傅里叶变换&#xff0c;用来分析频域信息&#xff0c;还有拉普拉斯变换和z变换&#xff0c;用于系统分析系统响应。短时傅里叶分析和小波分析用于时频分析。希尔伯特变换似乎听到的比较少…

网络运维与网络安全 学习笔记2023.11.25

网络运维与网络安全 学习笔记 第二十六天 今日目标 ACL原理与类型、基本ACL配置、高级ACL配置 高级ACL之ICMP、高级ACL之telnet ACL原理与类型 项目背景 为了企业的业务安全&#xff0c;要求不同部门对服务器有不同的权限 PC1不能访问Server PC2允许访问Server 允许其他所…