传统兼容性预设
传统兼容性实用工具集合。
此预设不包含任何规则,它对来自其他预设的生成的 CSS 应用后处理。
默认情况下,没有启用任何选项,你需要显式选择加入每个选项。
安装
bash
pnpm add -D @unocss/preset-legacy-compat
bash
yarn add -D @unocss/preset-legacy-compat
bash
npm install -D @unocss/preset-legacy-compat
ts
// uno.config.ts
import { defineConfig } from 'unocss'
import presetLegacyCompat from '@unocss/preset-legacy-compat'
export default defineConfig({
presets: [
// ...其他预设
presetLegacyCompat({
// 选项
commaStyleColorFunction: true,
}),
],
})
选项
commaStyleColorFunction
- 类型:
boolean
- 默认值:
false
将颜色函数(rgb()
和 hsl()
)从空格分隔转换为逗号分隔,以提高对旧版浏览器的兼容性。恢复 UnoCSS v0.57.0 之前的旧行为,该行为在 #3221 中更改为空格分隔以与 Tailwind CSS 对齐。
示例:
rgb(255 0 0)
->rgb(255, 0, 0)
rgb(255 0 0 / 50%)
->rgba(255, 0, 0, 50%)
hsl(0 100% 50% / 50%)
->hsla(0, 100%, 50%, 50%)