Skip to content

deepkolos/postcss-pxtocssvar

Repository files navigation

PostCSS Pxtocssvar Build Status

PostCSS plugin convert px to calc(var(--base)).

用于解决的情况:

  1. webview高度由内容撑开, 而preact + vw/rem布局无法撑开webview
  2. webview宽度不固定, 比如小卡webview加边距, 大卡webview占满, 而小卡内容需要在类似占满的比例展示
html {
    --base: calc(385 / 1080);
}

.foo {
  width: 100px;
}
html {
    --base: calc(385 / 1080);
}

.foo {
  width: calc(100px * var(--base));
}

Usage

postcss([ require('postcss-pxtocssvar') ])

See PostCSS docs for examples for your environment.

已知问题

减号需要加空格: 1px - 2px

About

plugin convert px to calc(var(--base)).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published