JSFiddle - React, Tailwind, and code Playground
HTML
<div id="foo"></div>
CSS
#foo {
width: 300px;
height: 200px;
background: skyBlue;
}
JavaScript
$(window).on('resize', function () {
var f = $('#foo');
var rightEdge = f.width() + f.offset().left;
var screenWidth = $(window).width();
console.log(screenWidth);
if (rightEdge-screenWidth > f.width()*.6) {
f.css('background','red');
}
else {
f.css('background','skyBlue');
}
});