layui.layer宽度自适应
maxWidth当area属性为auto时有效
layer.open({ skin: 'layui-layer-admin', title:"弹层标题", type: 1, maxmin: true, area: ['auto','90%'], maxWidth:1200, shadeClose: true, content: html });
设置百分比宽度,打开弹层后重置最大宽度(高度)和位置,实现宽度自适应
layer.open({ skin: 'layui-layer-admin', title:'标题', type: 1, maxmin: true, area: ['90%','90%'], shadeClose: true, content: html, success:function(layero,index,that){ layer.style(index,{maxWidth:1200}); //layer.style(index,{maxWidth:1200, maxHeight:800}); that.offset(); } });
高度自适应
layer.open({ skin: 'layui-layer-admin', title:'标题', type: 1, maxmin: true, area: ['90%','90%'], shadeClose: true, content: html, success:function(layero,index,that){ layer.iframeAuto(index); // 让 iframe 高度自适应 that.offset(); } });