基於 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;
`;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章