Like the title said. I have this code: https://jsfiddle.net/fwo9ym1o/
//javascript
var container = document.querySelector("#container");
container.style.display = "block";
//this is not working
//container.style.opacity = 1;
//this is working
setTimeout(function() {
container.style.opacity = 1;
}, 0);
/css
.container {
height: 200px;
width: 200px;
background-color: salmon;
display: none;
border-radius: 5px;
opacity: 0;
transition: opacity 2s ease-in-out;
}
//html
<div id="container" class="container"></div>
So, I've changed the container.style.display = "block";
then applied container.style.opacity = 1;
and the transition is not happening.
It works if I run everything in a new thread.
NOTE: I can't use visibility. It has to be display:none