css中添加屏幕自適應方法(rem)
只需要在公共css文件中添加下面代碼:設計稿以750px,基礎字體為20px為例,兼容性高,使用過程中px轉化為rem即可
/*豎屏*/ @media screen and (max-aspect-ratio: 13/9){ html {font-size:calc(100vw / 750 * 100);} @media screen and (min-width: 750px) { html{font-size:100px;max-width:750px;} } } /*橫屏*/ @media screen and (min-aspect-ratio: 13/9) { html {font-size:calc(100vmax / 750 * 100);} html .lockScreenTip {display:block;} html.input_focus .lockScreenTip {display:none;} @media screen and (min-width: 750px) { html{font-size:100px;max-width:750px;} } }