将窗口高度指定给文档高度

时间:2012-07-22 12:23:53

标签: javascript jquery html

关于如何实现这一点的任何想法?

$(document).css('height', $(window).height())

test http://ow.ly/cpqPA

$('body, html').height($(window).height())
alert('$(document).height(): ' + $(document).height() + "\n$('body').height(): " +   $('body').height() + "\n$('html').height(): " + $('html').height() + '\n$(window).height(): ' + $(window).height())

3 个答案:

答案 0 :(得分:2)

$("html,body").css("height", screen.height);​

My fiddle

答案 1 :(得分:1)

获取屏幕宽度和高度。

alert ("screen W = " + screen.width );
alert ("screen H = " + screen.height );

答案 2 :(得分:0)

试试这个css:

body {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
}