栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > JavaScript

微信小程序自定义弹出模态框禁止底部滚动功能

JavaScript 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

微信小程序自定义弹出模态框禁止底部滚动功能

图示:

wxml代码:


分享
电话咨询
立即报名







选择班次

{{item}}



取消
确定

wxss代码

.fix_bottom{
width: 100%;
height: 120rpx;
background: #fff;
position: fixed;
bottom: 0;
border-top: 1px solid #ccc;
display: flex;
}

.fix_bottom view{
width: 33.333%;
border-left: 1px solid #ccc;
line-height: 120rpx;
text-align: center;
font-size: 40rpx;
font-weight: bold;
}

.active{
color:#ffffff;
background: -moz-linear-gradient(left, #ff7b68, #ff5462);
 
 
 background: -webkit-gradient(linear,left,from(#ff7b68),to(#ff5462));
 
 background: -webkit-linear-gradient(left, #ff7b68, #ff5462);
 
 background: -o-linear-gradient(left, #ff7b68, #ff5462);
}



.modal-mask {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
background: #000;
opacity: 0.5;
overflow: hidden;
z-index: 9000;
color: #fff;
}

.modal-dialog {
width: 540rpx;
overflow: hidden;
position: fixed;
top: 40%;
left: 0;
z-index: 9999;
background: #f9f9f9;
margin: -180rpx 105rpx;
border-radius: 36rpx;
}

.modal-title {
height: 100rpx;
line-height: 100rpx;
font-size: 36rpx;
color: #fff;
text-align: center;
background: -moz-linear-gradient(left, #ff7b68, #ff5462);
 
 
 background: -webkit-gradient(linear,left,from(#ff7b68),to(#ff5462));
 
 background: -webkit-linear-gradient(left, #ff7b68, #ff5462);
 
 background: -o-linear-gradient(left, #ff7b68, #ff5462);
border-bottom: 1px solid #ccc;

}

.modal-content {

}

.concent_list{
width: 100%;
height: 100rpx;
border-bottom: 1px solid #ccc;
line-height: 100rpx;
text-align: center;
}

.modal-footer {
display: flex;
flex-direction: row;
height: 86rpx;
font-size: 34rpx;
line-height: 86rpx;
}

.btn-cancel {
width: 50%;
color: #666;
text-align: center;
border-right: 1px solid #dedede;
}

.btn-confirm {
width: 50%;
color: #ec5300;
text-align: center;
}

js代码

var value='小学升初中'
Page({


data: {
showModal: false,
concent_list:['小学升初中','初一升初二','初二升初三','初中升高中'],
curindex:-1
},


onLoad: function (options) {

},


onShow: function () {
},


showDialogBtn: function () {
this.setData({
showModal: true
})
},


hideModal: function () {
this.setData({
showModal: false
});
},


onCancel: function () {
this.hideModal();
},

on/confirm/i: function () {
this.hideModal();

})
},

choose:function(e){
var index=e.currentTarget.dataset.index
value = e.currentTarget.dataset.name
console.log(value)
this.setData({
curindex:index
})
}

})

模态框显示时禁止底部内容滚动可以在弹出时给底部包裹部分加上固定定位,模态框隐藏时取消固定定位

内容包裹的元素需要设置100%的宽度


底部所有内容内容内容

data数据的变化:

初始化时:

 position: 'auto',

模态框显示时:

position: 'fixed',

模态框隐藏时:

position: 'auto',

模态框显示时

总结

到此这篇关于微信小程序自定义弹出模态框禁止底部滚动功能的文章就介绍到这了,更多相关微信小程序弹出模态框内容请搜索考高分网以前的文章或继续浏览下面的相关文章希望大家以后多多支持考高分网!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/71033.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号