I have different elements in my html with different text sizes. I want them to be dynamic so that they display different font sizes for different screen sizes.
What would be the best way? Now I do it like this, but it makes the code look ugly:
<script>
$(window).resize(function(){
$('#first').css('font-size',($(window).width()*0.2)+'px');
$('h2').css('font-size',($(window).width()*0.02)+'px');
$('h1').css('font-size',($(window).width()*0.03)+'px');
For two elements, this will be fine, but I still have a lot. Not having much experience with html / css / javascript, so this is what I came up with.
As I study, I want to know what will be the best way.
Perhaps you have suggestions for improving this?
source
share