개인적인 프로그램/자바스크립트
동적인 탑화면
삽지리
2011. 12. 12. 16:21
출처 : 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");
}
}
);
이부분