基于 styled-components 的单位 px -> vw 自动转换

styled-components 基础上实现了 px -> vw 单位转换的功能

详细文档请参考: styled-components.com/docs

源码地址:https://github.com/hnzycfcfed/styled-px2vw

示例

style

Output

converted

Screenshot

screenshot

迁移

只需要修改 styled-components -> styled-px2vw 的导入即可

import styled, { createGlobalStyle,... } from 'styled-components';

const Button = styled.button`
  color: white;
  font-size: 36px;
  margin: 10px;
  height: 85px;
  border: 2px solid palevioletred;
  border-radius: 3px;
`;

to

import styled, { createGlobalStyle,... } from 'styled-px2vw';

const Button = styled.button`
  color: white;
  font-size: 36px;
  margin: 10px;
  height: 85px;
  border: 2px solid palevioletred;
  border-radius: 3px;
`;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章