zoukankan      html  css  js  c++  java
  • rem 单位计算javaScript

    <script>
    		 (function (doc, win) {
            var docEl = doc.documentElement,
                resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
                recalc = function () {
                    var clientWidth = docEl.clientWidth;
                    if (!clientWidth) return;
                    if(clientWidth>=640){
                        docEl.style.fontSize = '100px';
                    }else{
                        docEl.style.fontSize = 100 * (clientWidth / 640) + 'px';
                    }
                };
    
            if (!doc.addEventListener) return;
            win.addEventListener(resizeEvt, recalc, false);
            doc.addEventListener('DOMContentLoaded', recalc, false);
        })(document, window);
    	</script>
    

      

    <!DOCTYPE html>
    <html lang="en">
    <head>
    	<meta charset="UTF-8">
    
    	<meta name=viewport content="width=device-width, initial-scale=1">
    	<title>123</title>
    	<style>
    		*{margin:0; padding:0;}
    	</style>
    </head>
    <body>
    	<script type="text/javascript">
    		var oHtml = document.getElementsByTagName('html')[0];
    		var screenWidth = document.documentElement.offsetWidth || document.body.offsetWidth;
    		var nowFont = (screenWidth / 640 )*625 + "%";
    		oHtml.style.fontSize = nowFont;
    	</script>
    </body>
    </html>
    

      

  • 相关阅读:
    软件上线标准
    rap使用手册
    微服务
    什么是集合?
    什么是maven?maven中的pom文件是做什么的?
    什么是连接池?
    架构
    什么是反射?
    产品
    描述下fastJSON,jackson等等的技术
  • 原文地址:https://www.cnblogs.com/mingjixiaohui/p/5355400.html
Copyright © 2011-2022 走看看