zoukankan      html  css  js  c++  java
  • 自动垂直居中的js

    var _htmlheight;
    function start(){    
        _htmlheight=document.body.scrollHeight;
        resize();
        /*$("#copyright").css({(left:$(window).width()-1000)/2+"px"});
        $("#content").css({height:$(window).height()-59-208+"px"});
        $(".inner_content").css({top:_top+"px"});
        $(window).bind('resize',function(){
        _top=($(window).height()-59-208)/2>208?($(window).height()-59-208)/2:208;
            $("#copyright").css({(left:$(window).width()-1000)/2+"px"});
            $("#content").css({height:$(window).height()+$(window).scrollTop()-59+"px"});
            $(".inner_content").css({top:_top+"px"});
        });
        $(window).bind('scroll',function(){
            $("#content").css({height:$(window).height()-208+"px"});
        });*/
        $(window).bind('resize',function(){
            resize();
        });
    }
    function resize(){
        var _newHeight=$(window).height()-59<_htmlheight?_htmlheight:$(window).height()-59;
        $("#content").css({height:_newHeight-208+59+"px"});
        var _contentHeight=(_newHeight-208+59-50)/2<30?30:(_newHeight-208+59-50)/2;
        $(".inner_content").css({top:_contentHeight+"px"});
        document.getElementById("copyright").style.left=($(window).width()-1000)/2+"px";
    }

    没注释的部分对IE6和7以外的浏览器都是有效的。为了解决IE6和7只能写固定高度。否则最小高度无效了,没空深究,先MARK。

  • 相关阅读:
    AUTOSAR-文档阅读
    前端 html
    http协议
    python格式化输出
    IO模型
    协程函数
    伟大的GIL
    苑之歌(进程,线程)
    python之模块导入和包
    任性计算器
  • 原文地址:https://www.cnblogs.com/haimingpro/p/3655786.html
Copyright © 2011-2022 走看看