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。

  • 相关阅读:
    如何将你的AIR程序正常显示在iPhone5上?
    升级Flash Builder 4.7中的AIR SDK
    Flex AIR加载时全屏显示
    在Mac系统的安装Flash Builder 4.7开发工具
    What's XPath?
    XPath节点
    What's XML?
    65个源码下载网站
    [导入]轻松掌握Ajax.net系列教程
    MemberShip 示例
  • 原文地址:https://www.cnblogs.com/haimingpro/p/3655786.html
Copyright © 2011-2022 走看看