JSFiddle - React, Tailwind, and code Playground

HTML

<div class="container active">
</div>

CSS

.all-transition {
    -webkit-transition: all 1s ease;
    -moz-transition: all 1s ease;
    -o-transition: all 1s ease;
    transition: all 1s ease;
    }

.container {
    width: 200px;
    height: 15px;
    background-color: #ffd112;
}

.container.active {
    height: 200px;
}

.container.alert {
    background-color: #ff12d1;
}

JavaScript

setTimeout(function(){ // for Opera
    
// Remove active class, i.e. make container smaller.
var container = $('.container').removeClass('active');

// Trigger browser DOM reflow via reading offsetWidth property.
var foo = container[0].offsetWidth;
    
// Activate transition upon property change, but don't change properties.
$('.container').addClass('all-transition');

// Why am I seeing an animation? Isn't the order of the above commands considered?

setTimeout(function() {
    $('.container').addClass('alert');
}, 1000);

}, 1000);