2012-09-12 2 views

답변

4

Here은 내가 당신이 말하는 것에 대해 흥미로운 해결책입니다. 그들은 실제로 body 요소에 패딩/위치를 넣어 :

body { 
    position: absolute; 
    top: 20px; 
    left: 20px; 
    bottom: 20px; 
    right: 20px; 
    padding: 30px; 
    overflow-y: scroll; 
    overflow-x: hidden; 
} 
+1

그래, 작동합니다. 디자인의 나머지 부분을 맞추기 위해 약간 변경해야하지만 작동합니다. 대단히 감사합니다 : D –

+0

대단히 환영합니다! – Phil

0

변경을 스크롤 요소의 폭을. 예를 들어 ...

#div_content { 
    width: calc(100% - 20px); 
} 

그런 식으로, 페이지의 다른 요소는 영향을받지 않습니다. 예를 들어.

<div id="div_header">Welcome</div> 

<div id="div_content"> 
    Scrollable content goes here. 
</div> 

<div id="div_footer">©2015 by Whomever</div> 

샘플 CSS ...

#div_header { 
    position: absolute; 
    left: 0; 
    top: 0; 
    width: 100%; 
    height: 100px; 
} 

#div_content { 
    position: absolute; 
    left: 0; 
    top: 100px; 
    width: calc(100% - 20px); 
    height: calc(100% - 140px); 

    padding: 50px; 

    overflow-x: hidden; 
    overflow-y: auto; 
} 

#div_content::-webkit-scrollbar { 
    -webkit-appearance: none; 
} 

#div_content::-webkit-scrollbar:vertical { 
    width: 5px; 
} 

#div_content::-webkit-scrollbar:horizontal { 
    height: 5px; 
} 

#div_content::-webkit-scrollbar-thumb { 
    border-radius: 8px; 
    border: none; 
    background-color: #404040; 
} 

#div_footer { 
    position: absolute; 
    left: 0; 
    bottom: 0; 
    width: 100%; 
    height: 40px; 
} 
관련 문제