Files
admin-vben5/apps/web-antd/src/utils/flexible.ts
2025-07-10 17:52:54 +08:00

12 lines
391 B
TypeScript

function setRootFontSize(): void {
const baseWidth = 1920 // 设计稿宽度
const baseFontSize = 16 // 设计稿根字体
const screenWidth = window.innerWidth
const fontSize = (screenWidth / baseWidth) * baseFontSize
document.documentElement.style.fontSize = fontSize + 'px'
}
setRootFontSize()
window.addEventListener('resize', setRootFontSize)
export default setRootFontSize