JSFiddle - React, Tailwind, and code Playground

HTML

<div class="wide-div"></div>
<div class="small-div"></div>
<div id="button" class="button">Resize Elements</div>

CSS

body {
  margin: 0;
  padding: 0;
}

.wide-div {
  width: 2000px;
  height: 100px;
  background-color: orange;
}

.small-div {
  width: 150px;
  height: 100px;
  background-color: blue;
}

.button {
  margin-top: 10px;
  padding: 10px;
  color: white;
  background-color: #555;
  display: inline-block;
  cursor: pointer;
  text-transform: uppercase;
  border-radius: 5px;
  border: 1px solid #333;
}

JavaScript

$('#button').click(function () {
	var maxWidth = window.innerWidth;
  
  $('body').children().each(function () {
  	var $el = $(this);
    
  	if ($el.width() > maxWidth) {
    	$el.css('width', maxWidth);
    }
  });
});