Rem 轉 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
import presetRemToPx from '@unocss/preset-rem-to-px'
import { defineConfig } from 'unocss'
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
)。