Mobile FontSize is automatically amplified by the browser causing REM-Adaptive problems

Source: Internet
Author: User

Recent write mobile discovery, when I use REM to give HTML root elements a specified scale value, but will be WebView's built-in browse to add a layer of filtering to enlarge its value

Will eventually affect the REM layout. Finally on the internet for a long time an article written font boosting and my situation is very similar. Https://github.com/jin5354/404forest/issues/33.

So he solved it according to his plan, but it didn't work.

$ (function () {
$ (window). Resize (infinite);
function Infinite () {
var $html = $ (' html ');
var htmlwidth = $html. Width ();
var html_fontsize = 28.8/720 * htmlwidth;
$html. CSS ({
"Font-size": 28.8/720 * htmlwidth + "px"
});
if (html_fontsize = = parseint (getComputedStyle ($html [0]). FontSize)) {
Return
}
else {
var t_fs = html_fontsize/(parseint (getComputedStyle ($html [0]). fontsize)/html_fontsize);
$html. CSS ({
"Font-size": t_fs+ ' px '
});
}
}infinite ();
});
So I wrote a way to find the real fontsize. Write fontsize add to HTML, and then expand the scale according to the browser. In the calculation, you really need to write how many fontsize after zooming in to get the value of the computed you want.

Mobile FontSize is automatically amplified by the browser causing REM-Adaptive problems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.