時(shí)間:2023-09-05 23:54:01 | 來(lái)源:網(wǎng)站運(yùn)營(yíng)
時(shí)間:2023-09-05 23:54:01 來(lái)源:網(wǎng)站運(yùn)營(yíng)
自適應(yīng)網(wǎng)站頁(yè)面適配實(shí)現(xiàn)和基本原理講解:隨移動(dòng)端設(shè)備的普及,移動(dòng)web網(wǎng)站成為了前端工程師工作主攻點(diǎn)<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
自適應(yīng)工作原理也比較簡(jiǎn)單<div class="div"> <div class="div1">div1</div> <div class="div2">div2</div></div>.div { width: 100%; overflow: hidden;}.div1 { width: 20%; height: 50px; float: left;}.div2 { width: 50px; height: 50px; float: right;}
由于父級(jí)元素采用百分比的布局方式,隨著屏幕的拉伸,它的寬度會(huì)無(wú)限的拉伸(function(doc, win) { var docE1 = doc.documentElement, resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize', recalc = function() { var clientWidth = docE1.clientWidth; if (!clientWidth) return; docE1.style.fontSize = 15 * (clientWidth / 375) + 'px'; // 轉(zhuǎn)化為25rem }; if (!doc.addEventListener) return; win.addEventListener(resizeEvt, recalc, false); doc.addEventListener('DOMContentLoaded', recalc, false);})(document, window);
原創(chuàng)文章鏈接:https://www.toutiao.com/i6881889214640685571/關(guān)鍵詞:實(shí)現(xiàn),基本,原理,講解,適應(yīng)
客戶&案例
營(yíng)銷(xiāo)資訊
關(guān)于我們
客戶&案例
營(yíng)銷(xiāo)資訊
關(guān)于我們
微信公眾號(hào)
版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。