从jQuery中减去几个像素height() [英] Minus a few pixels from jQuery height()

查看:102
本文介绍了从jQuery中减去几个像素height()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,业余的问题在这里,但真的碰撞我的头。

Ok, amateur question here but im really bumping my head.

使用jQuery下面,我想添加margin-top:-100px;到高度值。

Using the jQuery below, i would like to add margin-top:-100px; to the height value.

请帮助!感谢:)

$(function () {
function HomePageSize() {
    $('#home').css({
        width: $(window).width(),
        height: $(window).height()
    });
}
$(window).resize(function () {
    HomePageSize();
});
HomePageSize();
});


推荐答案

如果您已经有margin-到某些元素,如#home,那么你可以尝试这个

If you already have margin-top of -100px assigned to some element like #home, then You can try this

$(function () {
function HomePageSize() {
$('#home').css({
    width: $(window).width(),
    height:  $(window).height() + parseInt($("#home").css("margin-top"))
});
}
$(window).resize(function () {
 HomePageSize();
});
 HomePageSize();
});

这篇关于从jQuery中减去几个像素height()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆