<script> (function (_D) { var _self = {}; _self.resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'; _self.Html = _D.getElementsByTagName("html")[0]; _self.widthProportion = function () { var p = Number((_D.body && _D.body.clientWidth || _self.Html.offsetWidth) / 1920).toFixed(3); // return p > 1.067 ? 1.067 : p < 0.444 ? 0.444 : p; return p > 1.067 ? p : p < 0.444 ? 0.444 : p; }; _self.changePage = function () { _self.Html.setAttribute("style", "font-size:" + _self.widthProportion() * 100 + "px"); }; _self.changePage(); if (!document.addEventListener) return; window.addEventListener(_self.resizeEvt, _self.changePage, false); document.addEventListener('DOMContentLoaded', _self.changePage, false); })(document); </script> </body> </html>
banner 全屏自适应
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
.banner-box{
width: 100%;
}
.img{
display: block;
width: 100%;
max-width: 1920px;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="banner-box">
<img class="img" src="http://lawhome.bjzzdk.com/uploads/images/20210122/f55685eb7138787b2e82a736f6f44cb1.png" alt="">
</div>
<div>
5555
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.banner-box{
max-width: 1920px; margin: 0 auto; height: 4rem;
background:url('http://lawhome.bjzzdk.com/uploads/images/20210122/f55685eb7138787b2e82a736f6f44cb1.png') no-repeat ;
background-size: 100%;
}
</style>
</head>
<body>
<div class="banner-box"> 666 </div>
<div class="content"> 555333333 </div>
<script> (function (_D) { var _self = {}; _self.resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'; _self.Html = _D.getElementsByTagName("html")[0]; _self.widthProportion = function () { var p = Number((_D.body && _D.body.clientWidth || _self.Html.offsetWidth) / 1920).toFixed(3); // return p > 1.067 ? 1.067 : p < 0.444 ? 0.444 : p; return p > 1.067 ? p : p < 0.444 ? 0.444 : p; }; _self.changePage = function () { _self.Html.setAttribute("style", "font-size:" + _self.widthProportion() * 100 + "px"); }; _self.changePage(); if (!document.addEventListener) return; window.addEventListener(_self.resizeEvt, _self.changePage, false); document.addEventListener('DOMContentLoaded', _self.changePage, false); })(document); </script> </body> </html>
<script> (function (_D) { var _self = {}; _self.resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'; _self.Html = _D.getElementsByTagName("html")[0]; _self.widthProportion = function () { var p = Number((_D.body && _D.body.clientWidth || _self.Html.offsetWidth) / 1920).toFixed(3); // return p > 1.067 ? 1.067 : p < 0.444 ? 0.444 : p; return p > 1.067 ? p : p < 0.444 ? 0.444 : p; }; _self.changePage = function () { _self.Html.setAttribute("style", "font-size:" + _self.widthProportion() * 100 + "px"); }; _self.changePage(); if (!document.addEventListener) return; window.addEventListener(_self.resizeEvt, _self.changePage, false); document.addEventListener('DOMContentLoaded', _self.changePage, false); })(document); </script> </body> </html>