jsフォントは画面サイズの変化に従う
674 ワード
/* rem , root rem rem, html 320/20 = 16px */
/* rem , root rem rem, html 320/20 = 16px */
function placeholderPic(){
var w = document.documentElement.offsetWidth;
document.documentElement.style.fontSize=w/40+'px';
}
placeholderPic();
window.onresize=function(){
placeholderPic();
}
コードはbodyの後ろに書いて、フォントはremで記入することを覚えていて、font-size:2.7 remに似ています;
このようなフォントサイズは画面サイズに従って変動し、
ここには自分でデバッグするパラメータがあります.documentです.documentElement.style.fontSize=w/40+'px';ここ40、あなたは自由に修正することができて、具体的なスクリーンがどれだけ大きいフォントに適しているかを知っています.