Preview:
// px -> rem 转换
const pxToRem = (px: number, base: number) => {
  if (base === 0) return "0";
  return (px / base).toFixed(4).replace(/\.?0+$/, "");
};

// rem -> px 转换
const remToPx = (rem: number, base: number) => {
  return (rem * base).toFixed(2).replace(/\.?0+$/, "");
};
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter