2016-10-04 44 views
0

需要關於滾動條和側邊菜單的一些想法?需要關於滾動條和側邊菜單的一些想法?

<body style=" margin: 0px; "> 
    <div style="position: absolute; width: 200px; height: 2000px; background: red;"></div> 
    <div style="width: 100%;height: 3000px;background: blue;"></div> 
</body> 

https://jsfiddle.net/ergjbvz5/

元格紅色側菜單和單元格藍色的主網站區域。

當用戶滾動頁面直到元素div紅色結束並且用戶仍然滾動頁面。我該如何做固定元素紅色和滾動元素div藍色?

+0

嘗試'位置:fixed'紅色,而不是'位置:absolute' –

+0

不起作用。但用is方式用戶不能滾動頁面直到元素紅色結束。 –

+0

只需爲x滾動添加「overflow-x:auto」 –

回答

0

它可以幫助你,試試這個:

<body style=" margin: 0px; "> 
 
    <div style="position: fixed; width: 30%; height: 100%; background: red;">Test sidebar</div> 
 
    <div style="margin-left:30%;height: 3000px;background: blue;"> 
 
     Test body 
 
    </div> 
 
</body>

+0

即可。但用is方式用戶不能滾動頁面直到元素紅色結束。 –

0

@Robert下你只需要紅色的div改變 「位置」。

<body style=" margin: 0px; "> 
 
    <div style="position: fixed; width: 200px; height: 2000px; background: red;">grghrughrughr<br> 
 
    grghrughrughr<br>grghrughrughr<br>grghrughrughr<br>grghrughrughr<br> 
 
    rrghrig</div> 
 
    <div style="width: 100%;height: 3000px;background: blue;"></div> 
 
</body>

+0

不起作用。但用is方式用戶不能滾動頁面直到元素紅色結束。 –

0

事情是這樣的:

<body style=" margin: 0px; "> 
 
    <div style="position: fixed; width: 200px; height: 100%; overflow:auto;"> 
 
     <div style="position: absolute; width: 100%; height: 2000px; background: red;"></div> 
 
    </div> 
 
    <div style="width: 100%;height: 3000px;background: blue;"></div> 
 
</body>

相關問題