zoukankan      html  css  js  c++  java
  • 让某标签始终出现在屏幕中间

    function setDivCenter(obj) {
                var top = ($(window).height() - $(obj).height()) / 2;
                var left = ($(window).width() - $(obj).width()) / 2;
                var scrollTop = $(document).scrollTop();
                var scrollLeft = $(document).scrollLeft();
                $(obj).css({ position: 'absolute', 'top': top + scrollTop, left: left + scrollLeft }).show();
                $(window).scroll(function () {
                    screenWidth = $(window).width();
                    screenHeight = $(window).height();
                    scrolltop = $(document).scrollTop();

                    objLeft = (screenWidth - obj.width()) / 2;
                    objTop = (screenHeight - obj.height()) / 2 + scrolltop;

                    obj.css({ left: objLeft + 'px', top: objTop + 'px' });
                });
            }

  • 相关阅读:
    JavaScript中弧度和角度的转换
    HTML <meta> Attribute
    rel 属性<small>H5保留属性</small>
    React学习笔记
    React学习笔记
    jQuery插件制作
    jQuery ajax
    js数据存贮之数组与json
    列表与表格的一些学习
    18-10-16学习内容总结
  • 原文地址:https://www.cnblogs.com/-maomao/p/4112421.html
Copyright © 2011-2022 走看看