REM是什么?
REM 又名 rootem 根元素(html)的 font-size。默认16px;
rem,em,px有什么区别?
- rem是相对单位,值基于根元素设置的字体尺寸(默认16px);
- em是相对单位,值相对当前对象内文本的字体尺寸;
- px是相对单位,值根据屏幕分辨率来确定😁。
响应式动态REM
在scss里我们可以直接填写原始像素
@function px ($px){
@return $px/$designWidth + rem;
}
$designWidth : 640;//屏幕尺寸
.child{
background:#ddd;
float:left;
width:pc(320);
height:px(160);
}