Js-Html 前端系列--页面撑开头尾

今天学习过程中,发现一个超实用的方法,就是当页面有尾部,但是内容又不多的情况下,让中间的内容把尾部撑到底部。

<script type="text/javascript">
        var statusTokenId="${statusTokenId!}";

        function register_box_w (a,b){
            var h = parseInt(document.documentElement.clientHeight||document.body.clientHeight);
            h = h-225-62;
            a.css({
                height:h+'px'
            });
            if(h>=600){
                b.css({
                    'padding-top':(h-650)/2+"px"
                })
            }

        }
        $(function(){
          register_box_w($(".login_content"),$(".loginmain"));//参数放登录的那个大框div
          $(window).resize(function(){
            register_box_w($(".login_content"),$(".loginmain"));//参数放登录的那个大框div
          });
        })
    </script>

方法中的数值可以根据实际情况更改。

Code is read far more than it's written
原文地址:https://www.cnblogs.com/ChickenTang/p/5655396.html