2012-09-12 28 views

回答

4

Here是我认为你在谈论的一个有趣的解决方案;他们实际上把身体元件上填充/位置:

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; 
} 
相关问题