I have been creating an audio player using vanilla JavaScript to manipulate the HTML element.
The player is of dynamic size, with all elem
Add the class .jcfResize
to any elements containing font which should be resized.
Add the following javascript code to the page/site:
function jcfResizeText() {
var elements = document.getElementsByClassName('jcfResize');
if (elements.length < 0) {
return;
}
_len = elements.length;
for (_i = 0; _i < _len; _i++) {
var el = elements[_i];
el.style.fontSize = "100%";
for (var size = 100; el.scrollHeight > el.clientHeight; size -= 10) {
el.style.fontSize = size + '%';
}
}
}
jcfResizeText();
window.addEventListener('resize', jcfResizeText);