2014-02-11 4 views
0

jQuery를 사용하여 사용자가 페이지의 아무 곳이나 스크롤 할 때 요소 스크롤을 시뮬레이션 할 수 있습니까? div가 100 % 높이이고 overflow: scroll을 사용하여 스크롤바를 표시합니다. 페이지 본문에는 100 % 높이이므로 스크롤 막대가 없습니다. 사용자가 페이지의 아무 곳이나 스크롤하려고 할 때 div가 스크롤되도록 만들 싶습니다. 이것이 가능한가?본문 스크롤시 한 요소 스크롤

감사합니다.

답변

2
++++++++++++++++++++++++++++++++++++ 
+  +     +  + 
+  +     +  + 
+ Left +  Content  + Right + 
+  +     +  + 
+  +     +  + 
++++++++++++++++++++++++++++++++++++ 

왼쪽 및 오른쪽 패널이 아니라 내용을 스크롤한다고 가정합니다. 왼쪽 및 오른쪽 패널에 고정 된 위치를 사용할 수 있습니다.

그래서 u는 페이지가 스크롤 될 때마다 콘텐츠 패널 만 스크롤 할 것이며 오른쪽 패널은 고정되어 있기 때문에 왼쪽 패널이 아닌 &이됩니다.

<html> 
<head> 
<style> 
    html,body,div 
    { 
    padding:0px; 
    margin:0px; 
    } 
    #left_panel, #right_panel 
    { 
     width:19%; 
     display:inline-block; 
     background-color:#22435D; 
     height:50%; 
     position:fixed; 
    } 
    #center_panel 
    { 
     margin-left:20%; 
     width:60%; 
     display:inline-block; 
     height:150%; 
     background-color:white; 
     color:#22435D; 
     border:1px solid #22435D; 
    } 
</style> 
</head> 
<body> 
    <div id="left_panel"> 
    </div> 
    <div id="center_panel"> 
     you content goes here 
     <br/> 
     you content goes here 
     <br/> 
     you content goes here 
     <br/> 
     you content goes here 
     <br/> 
     you content goes here 
     <br/> 
     you content goes here 
     <br/> 
     you content goes here 
     <br/> 
     you content goes here 
    </div> 
    <div id="right_panel"> 
    </div> 
</body> 
</html> 

이제 페이지를 스크롤하면 중앙 패널 만 스크롤됩니다.

관련 문제