출처 : http://www.williammalone.com/articles/create-html5-canvas-javascript-drawing-app/
핵심은
$(window).scroll(
function ()
{
if($(window).scrollTop() > $("#content").position().top + 20){
$("#tableOfContents").css("position", "fixed");
var marginTop = 20;// - $("#content").height();
/*$("#tableOfContents").css("margin-top", marginTop + "px");*/
$("#tableOfContents").css("top", "0");
}else{
$("#tableOfContents").css("position", "static");
$("#tableOfContents").css("margin-top", "20px");
}
}
);
이부분
핵심은
$(window).scroll(
function ()
{
if($(window).scrollTop() > $("#content").position().top + 20){
$("#tableOfContents").css("position", "fixed");
var marginTop = 20;// - $("#content").height();
/*$("#tableOfContents").css("margin-top", marginTop + "px");*/
$("#tableOfContents").css("top", "0");
}else{
$("#tableOfContents").css("position", "static");
$("#tableOfContents").css("margin-top", "20px");
}
}
);
이부분
'개인적인 프로그램 > 자바스크립트' 카테고리의 다른 글
ie에서 엘리먼트 이벤트를 잡아서 로그 찍고 싶을때. (0) | 2011.12.21 |
---|---|
innerHTML vs dom method 에 대해서 찾아봤다. (0) | 2011.12.21 |
javascript 오류와 캐릭터셋 (0) | 2011.10.26 |
폼 리사이징 (0) | 2011.10.26 |
ajax 와 xml 그리고 ie, ff (0) | 2011.10.26 |