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。

  • 相关阅读:
    python中用exit退出程序
    习题5-2 使用函数求奇数和 (15分)
    习题5-1 符号函数 (10分)
    练习5-3 数字金字塔 (15分)
    练习5-2 找两个数中最大者 (10分)
    练习5-1 求m到n之和 (10分)
    ubuntu使用教程
    图解HTTP 上
    Sublime Text 3 插件
    两千行PHP学习笔记
  • 原文地址:https://www.cnblogs.com/haimingpro/p/3655786.html
Copyright © 2011-2022 走看看