Skip to content

Rem to px 预设

将所有实用工具中的 rem 转换为 px。

源代码

安装

bash
pnpm add -D @unocss/preset-rem-to-px
bash
yarn add -D @unocss/preset-rem-to-px
bash
npm install -D @unocss/preset-rem-to-px
ts
// uno.config.ts
import { defineConfig } from 'unocss'
import presetRemToPx from '@unocss/preset-rem-to-px'

export default defineConfig({
  presets: [
    presetRemToPx(),
    // ...other presets
  ],
})

使用方法

html
<div class="m-2"></div>
css
.m-2 {
  margin: 0.5rem;
}
css
.m-2 {
  margin: 8px;
}

选项

baseFontSize

  • 类型: number
  • 默认值: 16

将 rem 转换为 px 的基准字体大小 (1rem = n px)。

Released under the MIT License.