2017-09-26 9 views
0

스크롤 가능한 div가 있다고 가정 해 보겠습니다.스크롤 막대 div의 일부에 초점을 맞추는 방법

<div style="width:300px;height:150px;overflow:scroll;"> 
    hi,<br /> 
    hi,<br /> 
    hi,<br /> 
    hi,<br /> 
    hi,<br /> 
    hi,<br /> 
    hi,<br /> 
    hi,<br /> 
    I WANT TO BE TOP OF THE SCROLLABLE DIV,<br /> 
    hi,<br /> 
    hi,<br /> 
    hi,<br /> 
    hi,<br /> 
    hi,<br /> 
    hi,<br /> 
    hi,<br /> 
    hi,<br /> 
</div> 

사업부는 상단의 'hi,'첫 시작으로 표시됩니다. 이제 이것은 예일뿐입니다. 스크롤 가능한 div에는이 예제보다 훨씬 많은 내용이 포함되어 있습니다.

나는 어떻게 든 div에 표시되는 콘텐츠의 특정 영역에 집중할 수 있기를 바랍니다. 따라서이 예제에서 스크롤바는 이미 약간 아래로 스크롤 될 것입니다. 여기서 'I WANT TO BE TOP OF THE SCROLLABLE DIV'이 맨 위에 표시됩니다. .

+1

사용 jQuery를 그것을 할) (초점을 맞출 수있는 방법;' –

답변

2

당신은 $ ("입력")`처럼 .. 태그를 사용하여 순수 HTML을

<a href="#scroll">click</a> 
 
<div style="width:300px;height:150px;overflow:scroll;"> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    <span id="scroll">I WANT TO BE TOP OF THE SCROLLABLE DIV,</span><br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
    hi,<br /> 
 
</div>

관련 문제