
Security News
Oxlint Introduces Type-Aware Linting Preview
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.
css-units-change
Advanced tools
css-units-change是一个将css中的单位互相转换的工具,这个插件支持同时将css中的多个单位转为同一个或者不同个单位。
正常写你的css
.wrapper {
margin: 1px 2rem;
}
css-units-change插件将根据你的配置对你的css的单位进行转换,例如你的rem要转为px,按照2倍的关系;
.wrapper {
margin: 1px 4px;
}
npm install css-units-change --save-dev
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: ["style-loader", "css-loader", "postcss-loader"]
}
]
}
}
然后创建postcss.config.js
module.exports = {
plugins: [
require('css-untis-change')(options)
]
}
将一个单位转为另外一个单位
{
originUnits: 'rem', // 待转换的单位
targetUnits: 'px', // 转换后的单位
decimalPlaces: 2, // 保留小数点,默认2位
multiple: 1, // 倍数
divisor: 2 // 除数
}
也支持将多个单位转为多个单位,即options改为数组的形式
[{
...
}, {
...
}]
目前小程序的单位均是rpx,但是可能H5转换的单位是px或者rem,该插件可支持单位互转;
FAQs
css的单位的互转的postcss插件
We found that css-units-change demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.