2011-07-06 5 views
0

http://jsfiddle.net/XjqmS/요소가 페이지 위쪽으로 스크롤되지 않도록하는 쉬운 방법이 있습니까?

내 콘텐츠 태그를 position:relative으로 수정하면 해당 요소가 그대로 유지되지 않습니다. 대신 이미지 위에 스크롤됩니다. 페이지가 스크롤되는 것이지, 요소는 스크롤하지 않게하고 싶습니다. 그게 가능하니?

+0

콘텐츠를 스크롤하지 않으려면 고정 위치를 지정하십시오. 나는 너에게 어떤 결과가 있는지 이해할 수 없다. – Jawad

+0

위치를 고정으로 설정하면 전체 페이지가 스크롤되지 않습니다. 그게 내 문제입니다. 스크롤 할 페이지가 필요하지만 실제 요소는 페이지가 아니라 스크롤입니다. – Kourtnie

+1

정말 미안합니다. 평균 IQ 미만입니다. 어느 img에 당신은 reffering 당신은 스크롤하고 싶은 요소? – Jawad

답변

1

나는 position:fixed 사용하여 문제를 제거 할 레이아웃을 다시 실행 생각 : D

여기를 참조하십시오 : http://jsfiddle.net/SAfLK/

HTML

<div id="wrapper"> 
    <div id="header">FIXED HEADER</div> 
    <div id="navigation">FIXED NAVIGATION</div> 
    <div id="content"> 
     CONTENT GOES HERE 
     <img src="http://www.dummyimage.com/200/" /> 
     <br /> 
     <img src="http://www.dummyimage.com/200/" /> 
     <br /> 
     <img src="http://www.dummyimage.com/200/" /> 
     <br /> 
     <img src="http://www.dummyimage.com/200/" /> 
     <br /> 
    </div> 
</div> 

CSS

/*adjust dimensions as necessary*/ 

html, body { 
    height:100%; 
    margin:0; 
    padding:0; 
} 

#wrapper { 
    position:relative; 
    height:100%; 
    width:400px; 
    background-color:#efe; 
    margin:0 auto; 
} 

#header { 
    height:50px; 
    background-color:#ded; 
} 

#navigation, #content { 
    position:absolute; 
    top:50px; /*set to header's height*/ 
    bottom:0; 
    left:0; 
    right:0; 
} 

/* #content and #navigation's width should add up to the #wrapper's width*/ 

#navigation { 
    width:150px; 
    background-color:#cdc; 
} 

#content { 
    overflow:auto; 
    width:250px; 
    left:150px; /*set to whatever navigations's width is*/ 
    background-color:#fef; 
} 
관련 문제