web
8 天以前 6e6127068f03a7fe655f1fd504c488f20683039f
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`;
}
resize()
window.addEventListener('resize', resize);