zoukankan      html  css  js  c++  java
  • js把div固定在页面的右下角

      在公司做材料系统中,需要做一个总是居于右下角的div,但是因为右边这部分本就是用iframe做的,所以是不好弄的。

          一开始,以为用position:fixed,一句css就可以完成,结果在iframe里面这个单页面倒是可以做到,但是一旦有加上模版页面,嵌在iframe中,就不行了。

      所以不断搜索啊,问度娘,看到了这个

          

    <script type="text/javascript">
    window.onscroll= window.onresize = window.onload = function (){
    var getDiv = document.getElementById('rightBottom');
    var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
    
    getDiv.style.left= document.documentElement.clientWidth - getDiv.offsetWidth+'px';
    getDiv.style.top = document.documentElement.clientHeight-getDiv.offsetHeight +scrollTop +'px';
    }
    
    </script>

          但是因为我们是嵌套在iframe中,所以我们找的肯定是夫级页面,所以,代码应该变成如下

    window.parent.onscroll = window.parent.onresize =  window.onload =function () {
      var oFix_box = document.getElementById('select-panel');
      var oscrollTop = window.parent.document.documentElement.scrollTop || window.parent.document.body.scrollTop;
      oFix_box.style.top = oscrollTop + window.parent.document.documentElement.clientHeight - oFix_box.offsetHeight - 224 + 'px';
      $("#select-panel").stop(true,true).animate({ "top": top1 }, 700);
    }
  • 相关阅读:
    python之面向对象编程
    python的模块引用和查找路径
    python的迭代器、生成器、三元运算、列表解析、生成器表达式
    python文件操作
    lesson4-图像分类-小象cv
    lesson3-神经序列模型I-小象
    fast ai环境配置
    YOLO
    lesson2-cnn-fastai
    mask-code-python
  • 原文地址:https://www.cnblogs.com/wanliyuan/p/3737368.html
Copyright © 2011-2022 走看看