deepkolos / postcss-pxtocssvar

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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)).

License:MIT License


Languages

Language:JavaScript 100.0%