zoukankan      html  css  js  c++  java
  • Javascript检测到你的分辨率,字号自动设置

    http://www.cnblogs.com/sink_cup/archive/2010/12/16/javascript_screen_width.html


    Javascript检测到你的分辨率,字号自动设置
     
    window.onresize

    <!--PageBeginHtml Block Begin-->
    <script type="text/javascript">
    function changeFontSize()
    {
      var font_size = screen.width / 64 + 'px';
      document.body.style.fontSize = font_size;
      if(document.getElementById('font_size')==null)
      {
         var pNode = document.createElement("p");
         pNode.id = 'font_size';
         document.body.insertBefore(pNode,document.body.childNodes[0]);
      }
      else
      {
         pNode=document.getElementById('font_size');
      }
        pNode.style.cssText = 'margin:0;background:#FFFFE1;border-bottom:1px solid #666666;';
        pNode.innerHTML = "Javascript检测到你的分辨率为" + screen.width + 'x' + screen.height + ',' + '字号自动设置为' + font_size;
    }
    changeFontSize();
    window.onresize=function()
    {
       changeFontSize();
    }
    </script>
  • 相关阅读:
    下载vue-devtools插件的步骤
    弄清 CSS3 的 transition 和 animation
    js与多行字符串
    swift 上手
    liunux 修改hostname
    linux 下使用配置文件
    linux安装oracle11g
    jQueryt过滤选择器
    Javascript并发模型和事件循环
    CSS生僻问题一网打尽
  • 原文地址:https://www.cnblogs.com/hakuci/p/2334055.html
Copyright © 2011-2022 走看看