web
8 天以前 2f0fa3545b539e8b6f952ea82a1ca2350c64a0e8
1
2
3
4
5
6
7
8
function resize () {
    const baseFontSize = 16
    const windowWidth = document.documentElement.clientWidth;
    const newVal = Math.round((windowWidth / 1920) * baseFontSize)
    document.documentElement.style.fontSize = `${newVal}px`;
}
 
window.addEventListener('resize', resize);