English 中文(简体)
固定头盔
原标题:Jquery scrolltop offsetting fixed header
  • 时间:2011-10-27 12:07:28
  •  标签:
  • jquery
  • html

I m 利用JQuery来顺利播放图像:

function smoothScroll图瓦卢o(hash) {
    $("html:not(:animated).,body:not(:animated)").animate({
        scroll图瓦卢op: $(hash).offset().top
    }, 650, function () {
        location.hash = hash;
    });
}
$(function () {
    $("#content-images li a[href*=#]").click(function () {
        this.blur();
        smoothScroll图瓦卢o(this.hash);
        return false;
    });
});

然而,我在该地有固定的av子,在上页的顶部。 当该网页降幅到下一个图像时,该页面将跳下与设想相隔的av。

我的问题是,我如何能够修改上述法典,以弥补我固定的 n的高度?

任何帮助都将受到高度赞赏。

图瓦卢

问题回答

变化:

scrollTop: $(hash).offset().top

:

scrollTop: $(hash).offset().top + $( #fixed_nav_bar ).outerHeight()

这应当考虑到固定的 n峰。

希望:

回答:

function smoothScrollTo(hash, t) { // two params
    $("html:not(:animated).,body:not(:animated)").animate({
        scrollTop: $(hash).offset().top + $( #fixed_nav_bar ).outerHeight()
    }, 650, function () {
        var tmp = t.id; // hold the id
        t.id =   ;      // remove it so we don t jump
        location.hash = hash;
        t.id = tmp;     // now that we didn t jump we can move it back
    });
}
$(function () {
    $("#content-images li a[href*=#]").click(function () {
        this.blur();
        smoothScrollTo(this.hash, this); // two args
        return false;
    });
});




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签