伸缩的绝对位置div

时间:2018-11-23 14:56:10

标签: javascript jquery html css flexbox

我有一个将在处理请求时显示的div。我想要这样:

  1. 网页屏幕变黑并具有一定的透明度
  2. 发黑后,居中的div必须从中心缩放,并且其元素在中心对齐。

但是,当执行Javascript时,div会从右下角缩放到左上角,并且右下角位于屏幕的绝对中心。

有没有办法使div的中心从他的中心和div_fundo_escuro_total的绝对中心开始?

$("#div_fundo_escuro_total").fadeIn({
  duration: 300,
  complete: function() {
    $("#div_info_fundo_escuro").show('scale', {}, 250);
  }
});
#div_fundo_escuro_total {
  width: 100%;
  height: 100%;
  z-index: 2000;
  background-color: rgba(0, 0, 0, 0.3);
  position: fixed;
  top: 0px;
  left: 0px;
  display: none;
}

#div_info_fundo_escuro {
  width: 40%;
  min-height: 60%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px #444444 solid;
  box-shadow: 2px 4px 10px 2px #555;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<div id="div_fundo_escuro_total">
  <div style="width:100%; height: 100%; position: relative;">
    <div id="div_info_fundo_escuro">
      Processando this foobar
    </div>
  </div>
</div>

0 个答案:

没有答案