在 styled-components 基礎上實現了 px -> vw 單位轉換的功能
詳細文檔請參考: styled-components.com/docs
源碼地址:https://github.com/hnzycfcfed/styled-px2vw
示例
Output
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;
`;