JSFiddle - React, Tailwind, and code Playground

HTML

<div>
    Below, you should see a blue div in a modern browser and a red div in an old browser (IE&lt9).
    In both cases it should be rotated in the same angle and positioned the same so it just touches the frame on the left.
    
</div>
<br/>
<!--[if lte IE 8]><div class="lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <div> <!--<![endif]-->
    <div class='ie-rotation-fixer'>
        <div id="target"><div id="inner">A</div></div>
    </div>
</div>

CSS

#target {
    width : 20px; 
    height : 80px; 
    background-color: blue;
    -webkit-transform : rotate(-30deg);
    -moz-transform : rotate(-30deg);
    -ms-transform : rotate(-30deg);
    -o-transform : rotate(-30deg);
    transform : rotate(-30deg);
    zoom: 1;
    position : relative;
    left : 19px;
    color : white;
}
#inner {
    width : 100%;
    height : 50%;
    background-color : black;
}
.lt-ie9 #target {
    background-color: red;
}
.lt-ie9 .ie-rotation-fixer {
    position : relative;
    left : 10px;
}

JavaScript

// These variables are all you need to calculate the fix
var h = 80; // height in pixels
var w = 20; // width in pixels
var deg = -30; // rotation degrees
////////////////////////////////////////////////////////

// Calculate the radian and wrap around PI/2
var rad = deg * Math.PI / 180;

// Precalculate cos and sin for the rotation
var real_cos = Math.cos(rad);
var real_sin = Math.sin(-rad);

rad %= 2 * Math.PI;
if (rad < 0) rad += 2 * Math.PI;
rad %= Math.PI;
if (rad > Math.PI / 2) rad = Math.PI - rad;

// Precalculate cos and sin for the fix
var cos = Math.cos(rad);
var sin = Math.sin(-rad);

var top_fix = (h - h * cos + w * sin)/2;
var left_fix = (w - w * cos + h * sin)/2;

// Apply the rotation on the element
$('.lt-ie9 #target').css({
    filter : "progid:DXImageTransform.Microsoft.Matrix(M11="+real_cos+", M12="+real_sin+", M21="+(-real_sin)+", M22="+real_cos+", sizingMethod='auto expand')"
})
// And apply the location fix on the fixer
$('.lt-ie9 .ie-rotation-fixer').css({
    top : top_fix + 'px',
    left : left_fix + 'px'
})