gpt4 book ai didi

javascript - jquery 我使用 .css() 将最小高度缩放到窗口高度的错误在哪里

转载 作者:太空宇宙 更新时间:2023-11-04 11:38:09 25 4
gpt4 key购买 nike

我正在编写一个脚本,将我的英雄单元的最小高度缩放为窗口高度减去标题。除非其子容器的高度大于窗口。我一定是在某个地方偏离了我的语法,因为到目前为止我所拥有的没有用。

$(function () {

function heroUnitHeight() {
if( $('.hero-unit').height < $(window).height ) {
$('.hero-unit').css("min-height", ( $(window).height() - $('header').height()) + "px");
} else {
$('.hero-unit').css("min-height", $('.quick-search').height());
}
}

$(document).ready(function() {
$('.hero-unit').css("padding-top", ( $('.hero-unit').height() - $('.quick-search').height()) / 4 + "px");
heroUnitHeight();
});
$(window).resize(function() {
$('.hero-unit').css("padding-top", ( $('.hero-unit').height() - $('.quick-search').height()) / 4 + "px");
heroUnitHeight();
});

});

最佳答案

只有在 heroUnitHeight 函数的第一个 if 语句中,你调用的 height 没有括号:$('.hero-unit').height$(窗口).高度

关于javascript - jquery 我使用 .css() 将最小高度缩放到窗口高度的错误在哪里,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31579613/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com