JSFiddle - React, Tailwind, and code Playground
HTML
<div id="container">
<div id="fill">
sample
</div>
</div>
CSS
#container {
position: absolute;
margin: 0;
padding: 0;
top: 0; bottom: 0; left: 0; right: 0;
overflow: hidden;
}
#fill {
margin: 0;
display: inline-block;
transform-origin: 0 0;
}
JavaScript
function fillWithText () {
var fill = document.getElementById('fill');
var container = document.getElementById('container');
var totalHeight = container.clientHeight;
var totalWidth = container.clientWidth;
var currentHeight = fill.clientHeight;
var currentWidth = fill.clientWidth;
var scaleX = totalWidth / currentWidth;
var scaleY = totalHeight / currentHeight;
fill.style.transform = 'scale(' + scaleX + ',' + scaleY + ')';
};
window.addEventListener('resize', fillWithText, false);
fillWithText();