layui iframe弹出层高度自适应,并垂直居中

1、高度自适应:

layui iframe弹出层高度自适应,并垂直居中_第1张图片

代码:

success: function(layero, index) {
  layer.iframeAuto(index);

},


2、垂直居中

进入layer.js,增加几行代码。具体如图:

layui iframe弹出层高度自适应,并垂直居中_第2张图片

代码:

  var bodyHH = document.documentElement.clientHeight;
  if(heg + titHeight + btnHeight > $(window).height()){
    layero.css({height:$(window).height(),
      top:(bodyHH-$(window).height())*0.5});
    layero.find('iframe').css({height:$(window).height()-titHeight-btnHeight,
      top:(bodyHH-$(window).height())*0.5});
  }else{
    layero.css({height: heg + titHeight + btnHeight,
      top:(bodyHH-(heg + titHeight + btnHeight))*0.5});
    layero.find('iframe').css({height: heg,
      top:(bodyHH-(heg + titHeight + btnHeight))*0.5});   
  }

你可能感兴趣的:(js,layui)