Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

px is converted to em when using with postcss-next #8

Open
vvenv opened this issue Sep 13, 2016 · 4 comments
Open

px is converted to em when using with postcss-next #8

vvenv opened this issue Sep 13, 2016 · 4 comments

Comments

@vvenv
Copy link

vvenv commented Sep 13, 2016

following:

.c-checkbox {
  height: 48px; /*px*/
  &.checked {
    transform: translate3d(32px, 0, 0); /*px*/
  }
}

will be converted to:

.c-checkbox {
  height: 0.64rem ;
}

.c-checkbox.checked {
  -webkit-transform: translate3d(0.426667rem, 0, 0);
  transform: translate3d(0.426667rem, 0, 0) ;
}

and that is NOT expected

@songsiqi
Copy link
Owner

Please provide your postcss config.

@facesea
Copy link

facesea commented Jul 13, 2017

我有相同的问题,原因是因为postcss里配置多个插件时,会多次调用px2rem,第一次调用px2rem时会删除/*no*/,后面再调用px2rem就检测不到/*no*/,暂时解决方案是注释掉px2rem.js的129行:

line128  } else if (nextDeclaration.comment.trim() === config.keepComment) { // no transform
line129     // declarations.splice(j + 1, 1); // delete corresponding comment
line130  } else {

若有更优雅的解决方案请告知,谢谢~ @songsiqi @crossjs

@vvenv
Copy link
Author

vvenv commented Jul 14, 2017

@facesea 我的方案是不用这个工具,自己写了个 https://github.com/crossjs/postcss-flexible

使用 rem(),dpr() 等方法,虽然侵入性强了点,但适配更好,比如一行有多个需要转换的情况。

@wanguohong
Copy link

@facesea 解决了困扰半天的问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants