JSFiddle - React, Tailwind, and code Playground

by jinglesthula

HTML

<div class="parent altLayout">
    <div class="child">hi</div>
</div>

CSS

.parent {
    height: 40px;
    background: #06f;
    padding: 30px;
}

.child {
    height: 40px;    
    background: #eef;
}

.altLayout .child {
    display: inline;
}

body {
    font-family: arial;
}

JavaScript

// Uncomment each block *separately* to see the effect

/*
This first one is the expected result, regardless of whether the .altLayout .child rule was applied before or after the show/hide calls.  The rule may be applied/'un-applied' either by js as here, or by media queries by rotating a device or resizing a browser window.
*/
// w/o altLayout
/* * /
$('.parent').removeClass('altLayout');
/* */

// Case 1
// remove before hide/show
/* * /
$('.parent').removeClass('altLayout');
$('.child').hide();
$('.child').show();
/* */

// Case 2
// remove after hide/show
/* * /
$('.child').hide();
$('.child').show();
$('.parent').removeClass('altLayout');
/* */