Scale position absolute div with flex












0















I have a div that will be shown when processing a request. I would like that:




  1. The web page screen becomes black with some tranparency

  2. After the blacking, a div in center must appear scaling from center and with her elements aligned in center.


However when the Javascript is executed the div scales from bottom-right to top-left with the bottom-right corner in the absolute center of the screen.



Is there a way to make the center of the div scale from his center and in the absolute center of the 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>












share|improve this question




















  • 1





    Do you need to use jQuery for the scale? If you were to use a CSS transform scale, you could use transform-origin to scale from the centre.

    – DBS
    Nov 23 '18 at 15:02











  • No, I'm open to any other suggestions for doing this. Thank you

    – WitnessTruth
    Nov 23 '18 at 15:06






  • 1





    Then transform:scale transform-origin

    – Smollet777
    Nov 23 '18 at 15:25


















0















I have a div that will be shown when processing a request. I would like that:




  1. The web page screen becomes black with some tranparency

  2. After the blacking, a div in center must appear scaling from center and with her elements aligned in center.


However when the Javascript is executed the div scales from bottom-right to top-left with the bottom-right corner in the absolute center of the screen.



Is there a way to make the center of the div scale from his center and in the absolute center of the 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>












share|improve this question




















  • 1





    Do you need to use jQuery for the scale? If you were to use a CSS transform scale, you could use transform-origin to scale from the centre.

    – DBS
    Nov 23 '18 at 15:02











  • No, I'm open to any other suggestions for doing this. Thank you

    – WitnessTruth
    Nov 23 '18 at 15:06






  • 1





    Then transform:scale transform-origin

    – Smollet777
    Nov 23 '18 at 15:25
















0












0








0








I have a div that will be shown when processing a request. I would like that:




  1. The web page screen becomes black with some tranparency

  2. After the blacking, a div in center must appear scaling from center and with her elements aligned in center.


However when the Javascript is executed the div scales from bottom-right to top-left with the bottom-right corner in the absolute center of the screen.



Is there a way to make the center of the div scale from his center and in the absolute center of the 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>












share|improve this question
















I have a div that will be shown when processing a request. I would like that:




  1. The web page screen becomes black with some tranparency

  2. After the blacking, a div in center must appear scaling from center and with her elements aligned in center.


However when the Javascript is executed the div scales from bottom-right to top-left with the bottom-right corner in the absolute center of the screen.



Is there a way to make the center of the div scale from his center and in the absolute center of the 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>








$("#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>





$("#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>






javascript jquery html css flexbox






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 22:55









Michael_B

146k47235342




146k47235342










asked Nov 23 '18 at 14:56









WitnessTruthWitnessTruth

178111




178111








  • 1





    Do you need to use jQuery for the scale? If you were to use a CSS transform scale, you could use transform-origin to scale from the centre.

    – DBS
    Nov 23 '18 at 15:02











  • No, I'm open to any other suggestions for doing this. Thank you

    – WitnessTruth
    Nov 23 '18 at 15:06






  • 1





    Then transform:scale transform-origin

    – Smollet777
    Nov 23 '18 at 15:25
















  • 1





    Do you need to use jQuery for the scale? If you were to use a CSS transform scale, you could use transform-origin to scale from the centre.

    – DBS
    Nov 23 '18 at 15:02











  • No, I'm open to any other suggestions for doing this. Thank you

    – WitnessTruth
    Nov 23 '18 at 15:06






  • 1





    Then transform:scale transform-origin

    – Smollet777
    Nov 23 '18 at 15:25










1




1





Do you need to use jQuery for the scale? If you were to use a CSS transform scale, you could use transform-origin to scale from the centre.

– DBS
Nov 23 '18 at 15:02





Do you need to use jQuery for the scale? If you were to use a CSS transform scale, you could use transform-origin to scale from the centre.

– DBS
Nov 23 '18 at 15:02













No, I'm open to any other suggestions for doing this. Thank you

– WitnessTruth
Nov 23 '18 at 15:06





No, I'm open to any other suggestions for doing this. Thank you

– WitnessTruth
Nov 23 '18 at 15:06




1




1





Then transform:scale transform-origin

– Smollet777
Nov 23 '18 at 15:25







Then transform:scale transform-origin

– Smollet777
Nov 23 '18 at 15:25














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53448908%2fscale-position-absolute-div-with-flex%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53448908%2fscale-position-absolute-div-with-flex%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Berounka

Sphinx de Gizeh

Different font size/position of beamer's navigation symbols template's content depending on regular/plain...