<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>
原文地址:https://blog.csdn.net/qq_41429765/article/details/134617006
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_16395.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。