<div class="text">font-size: </div>
.text {
font-size: max(5vw, 20px);
}
/* Helpers*/
BODY {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
font: 22px/1 Trebouchet MS, Arial, sans-serif;
}
DIV {
padding: 1em;
border: .5em solid turquoise;
}
DIV::after {
content: attr(data-size)
}
const elements = document.querySelectorAll('DIV');
const showWidth = () => {
elements.forEach(element => {
const style = window.getComputedStyle(element, null);
element.dataset.size = style.fontSize;
})
}
showWidth();
window.addEventListener('resize', showWidth);
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.