제대로 위치 문서가 대상의 오프셋 상단이되도록합니다. 귀하의 경우 이것은 품목이 귀하의 헤더 뒤에 위치 함을 의미합니다. 이 문제를 해결할 수있는 한 가지 방법은 항목을 다시 배치 할 때 머리글 높이를 보완하기 위해 앵커 클릭 이벤트를 재정의하는 것입니다. 여기
어떤이 작업을 수행 할 것 jQuery를 ...
$(function(){
$("a[href^='#']").on("click.scrollFix", function(e) {
// cancel the click of the a href from taking you to the
// anchor by normal means
e.preventDefault();
// instead find the element and scroll to the elements position - the height of the header
var targetSelector = $(this).attr("href"),
targetTop = $(targetSelector).offset().top,
headerHeight = $("#header").outerHeight(true);
$(document).scrollTop(targetTop - headerHeight);
});
});
하고 여기에 고정 된 헤더와 일부 정크 내용 :
http://jsfiddle.net/QjheK/
당신이 할 수있는 사용 예와 작업 바이올린의 지금까지 해 온 것의 피들 (www.jsfiddle.net)을 만드십시오. – BeNdErR
머리글 아래의 'div # sponsor'에 50px 이상의 'padding-top'을 추가 하시겠습니까? – Brewal
스크롤 막대를 클릭해도 관련성이 없습니다. 작업 레이아웃을 만들어야합니다. 지금 수동으로 스크롤해도 동일한 문제가 발생합니다. – avrahamcool