I would like to know if there's a way to change the body font-size according to the screen width.
For example: When the screen's width increases with 1px , the body font-size would change from 100% to 100.1%
Thanks
you should use window resize event. For example, following code could be one.
var prevWidth = $(window).width();
$(window).resize(function() {
$('body').css('font-size',(100 + ($(window).width() - prevWidth) / 100) + '%');
prevWidth = $(window).width();
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.