JSFiddle - React, Tailwind, and code Playground

by Alexis López Espinoza

HTML

<section></section>
<p></p>
<img src = "http://static3.absolutcaribe.com/wp-content/uploads/2009/09/playa-placencia.jpg" />
<article>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</article>

CSS

section{
	width: 20em;
	height: 10em;
	background: red;
}

p{
	width: 15em;
	height: 7.5em;
	background: green;
}

article{
	width: 25em;
	height: 10em;
	text-align: justify;
	overflow: auto;
	border: .1em solid;
}

JavaScript

/*!
 * Resize the window and preserve the original aspect ratio of DOM elements
 * @author: Alexis López (@AlexisThrasher)
 */

$.fn.extend({
	responsive: function(){
		window.measures = window.measures || {};
		window.flag = window.flag || false;
		
		var width = $(window).width(),
			height = $(window).height(),
            props = null;
				
		if (!window.flag){		
			$(this).each(function(index){
				window.measures[index] = {
					elem: this,
					perWidth: $(this).width() / width,
					perHeight: $(this).height() / height
				};
			});
			window.flag = true;
		}
		
		props = window.measures;
		
		for (var i in props){
			$(props[i].elem).css({
				width: props[i].perWidth * width,
				height: props[i].perHeight * height
			});
		}
	}
});

$(window).on("resize load", function(){
	$("body *:not(script)").responsive();
});