JSFiddle - React, Tailwind, and code Playground

by Zumzum

HTML

<div class="x"></div>
<div class="y"></div>

CSS

.x {
  background-color: #713b3b;
  height: 30px;
  width: 400px;
}

.y {
  height: 30px;
  width: 100%;
}

JavaScript

if ($('.x').css('width') <= '500px') {
  $('.y').css({
    'background-color': 'red'
  });
}

if ($('.x').css('width') <= '400px') {
  $('.y').css({
    'background-color': 'green'
  });
}

if ($('.x').css('width') <= '300px') {
  $('.y').css({
    'background-color': 'yellow'
  });
}