How to implement a web page that scales when the browser window is resized?

后端 未结 11 860
伪装坚强ぢ
伪装坚强ぢ 2020-12-29 15:42

How to implement a web page that scales when the browser window is resized?

I can lay out the elements of the page using either a table or CSS float sections, but i

11条回答
  •  不思量自难忘°
    2020-12-29 16:15

    < body onresize="resizeWindow()" onload="resizeWindow()" > PAGE < /body >

        /**** Page Rescaling Function ****/
    
        function resizeWindow() 
        {
            var windowHeight = getWindowHeight();
            var windowWidth = getWindowWidth();
    
            document.getElementById("content").style.height = (windowHeight - 4) + "px";
        }
    
        function getWindowHeight() 
        {
            var windowHeight=0;
            if (typeof(window.innerHeight)=='number') 
            {
                windowHeight = window.innerHeight;
            }
            else {
                if (document.documentElement && document.documentElement.clientHeight) 
                {
                    windowHeight = document.documentElement.clientHeight;
                }
                else 
                {
                    if (document.body && document.body.clientHeight) 
                    {
                        windowHeight = document.body.clientHeight;
                    }
                }
            }
            return windowHeight;
        }
    

    The solution I'm currently working on needs a few changes as to width otherwise height works fine as of so far ^^

    -Ozaki

提交回复
热议问题