課程
/前端開(kāi)發(fā)
/WebApp
/Hello,移動(dòng)WEB
設(shè)計(jì)師給我的圖片大小是750px的寬度,涉及到px的地方,我怎么把px轉(zhuǎn)換為rem呢
2017-02-18
源自:Hello,移動(dòng)WEB 3-5
正在回答
!new function(){var a=this;a.width=750,a.fontSize=100,a.widthProportion=function(){var b=(document.body&&document.body.clientWidth||document.getElementsByTagName("html")[0].offsetWidth)/a.width;return b>1?1:b},a.changePage=function(){document.getElementsByTagName("html")[0].setAttribute("style","font-size:"+a.widthProportion()*a.fontSize+"px !important")},a.changePage(),window.addEventListener("resize",function(){a.changePage()},!1)};
示例代碼:
<!DOCTYPE html>
<html>
<head>
?????/*每個(gè)頁(yè)面都需要引入rem.js 代碼如上*/
? ? <script src="js/rem.js"></script>
? ? <style>
? ? ? ? /*設(shè)計(jì)圖中div的寬度為750px 高度為100px*/
? ? ? ? div{width: 7.5rem;height: 1rem;}
? ? </style>
</head>
<body>
? ? <div>內(nèi)容</div>
</body>
</html>
rem大小相對(duì)于html root 的font-size;
<html ?style="font-size:20px">
<div style="width:2rem">這個(gè)div的寬度就是40px</div>
</html> ? ?
V_0
舉報(bào)
課程介紹移動(dòng)web的開(kāi)發(fā)基礎(chǔ),排版布局,常見(jiàn)移動(dòng)web問(wèn)題
2 回答dp和px的換算到底是什么呢
3 回答px與dp
2 回答dp和px
2 回答px的計(jì)算
3 回答為什么我算出來(lái)是 px*2=pd?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2018-07-05
!new function(){var a=this;a.width=750,a.fontSize=100,a.widthProportion=function(){var b=(document.body&&document.body.clientWidth||document.getElementsByTagName("html")[0].offsetWidth)/a.width;return b>1?1:b},a.changePage=function(){document.getElementsByTagName("html")[0].setAttribute("style","font-size:"+a.widthProportion()*a.fontSize+"px !important")},a.changePage(),window.addEventListener("resize",function(){a.changePage()},!1)};
示例代碼:
<!DOCTYPE html>
<html>
<head>
?????/*每個(gè)頁(yè)面都需要引入rem.js 代碼如上*/
? ? <script src="js/rem.js"></script>
? ? <style>
? ? ? ? /*設(shè)計(jì)圖中div的寬度為750px 高度為100px*/
? ? ? ? div{width: 7.5rem;height: 1rem;}
? ? </style>
</head>
<body>
? ? <div>內(nèi)容</div>
</body>
</html>
2017-02-20
rem大小相對(duì)于html root 的font-size;
<html ?style="font-size:20px">
<div style="width:2rem">這個(gè)div的寬度就是40px</div>
</html> ? ?