css弹窗动画效果,示例弹窗从底部弹出
从底部弹出来,有过渡动画效果
用max-height可以自适应内容的高度,当内容会超过最大高度时可以在弹窗里加个scroll-view
弹窗不能用v-if来隐藏,不然transition没效果,transition只能对已有dom元素起效果,所以用透明和visibility来隐藏
<view @tap="showpop">弹出来</view>
<view class="popWai" :class="isshowpop?'popWaiAc':''" @tap="closepop">
<view class="popNei" :style="isshowpop?'bottom:0':'bottom:-680rpx'">
<div>发顺丰萨芬撒</div>
</view>
</view>
data(){
return{
isshowpop:false,
}
},
methods:{
showpop(){
this.isshowpop = true;
},
closepop(){
this.isshowpop = false;
},
}
.popWai{
position: fixed;
top: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.5);
width: 100%;
height: 100%;
z-index: 99;
opacity: 0;
visibility: hidden;
overflow: hidden;
}
.popNei{
position: absolute;
left: 0;
width: 100%;
max-height: 680rpx;
background-color: #fff;
transition: all 0.5s ease-out;
}
.popWaiAc {
opacity: 1;
visibility: visible;
}