JSFiddle - React, Tailwind, and code Playground

HTML

<div class="left"></div>

CSS

.left{
    background: red;
    height: 100px;
    margin: auto;
}

JavaScript

function resize_div(selector){
    var curr_width = selector.width(); // get the current width
    new_width = curr_width - 100;
    $('.left').css('width', new_width);
}

$(document).ready(function(){
    $('.left').css('width', '100%'); // set the width to 100% initially
    resize_div($('.left')); // then resize width on document ready
});
$(window).resize(function(){
    $('.left').css('width', '100%'); // set the width to 100% initially
    resize_div($('.left')); // resize width everytime the window is resized
});