var scale = 1 / window.devicePixelRatio;
document.querySelector('meta[name="viewport"]').setAttribute('content', 'initial-scale=' + scale + ', maximum-scale=' + scale + ', minimum-scale=' + scale + ', user-scalable=no');
document.documentElement.style.fontSize = document.documentElement.clientWidth / 10 + 'px';
//scss
$baseFontSize : 75;
@function r( $px ){
@return $px/$baseFontSize + rem;
}
body {
font-family: Roboto-Regular, Helvetica, STHeiTi, sans-serif;
line-height: 1.2;
}
.text{
font-size: r(20);
}
.s_a{
text-align: center;
font-size: r(10);
}
.s_b{
font-size: r(20);
}
.s_c{
font-size: r(28);
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
<title>index</title>
</head>
<body>
<div class='text'>Sed sit amet sem nec nisi sodales laoreet at et</div>
<div class="s_a">New juanpi special</div>
<p class="s_b">75% off·shipping·Limited quantity</p>
<div class="s_c"><a href="baidu.com">See more details on the App</a>
</div>
</body>
</html>
class to'text'元素设置'font-size:r(30);'和'font-size:r(20);'其他页面元素之后fontSize的性能完全不同,为什么呢?
如果你删除'a'标签内的's_c'元素,也会发生这种情况。
我需要你的帮助! :(