Source:Script

Device Pixel Ratio Sync

Injects a script to keep the --dpr custom property on the root element synchronized with window.devicePixelRatio, updating on resize or zoom.

crt-screen-dpi.tsx
const devicePixelRatioScript = `
const syncDevicePixelRatio = () => {
document.documentElement.style.setProperty(
'--dpr',
String(window.devicePixelRatio || 1),
);
};
syncDevicePixelRatio();
window.addEventListener('resize', syncDevicePixelRatio);
`;
tsx

Experimente