[英]Javascript Resize Element Based on Browser Height
我试图使用Javascript / jQuery根据窗口的高度调整网站的一部分。
我的代码如下:
jQuery.event.add(window, "load", resizeFrame);
jQuery.event.add(window, "resize", resizeFrame);
function resizeFrame()
{
var h = $(window).height();
$(".main-wrapper").css('height', (h) ? h - 100);
}
我究竟做错了什么? 它似乎没有调整main-wrapper控制的部分的大小。
条件语句中有错误(h) ? h - 100
(h) ? h - 100
。 您必须为if (h)
求值为false提供值。 正确的语法是(cond?exp true :exp false )
$(".main-wrapper").css('height', h ? h - 100 : default_value );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.