2013-07-11 64 views
1

要求:啓用鼠標滾輪垂直滾動而不顯示滾動條並保持背景。啓用不顯示垂直滾動條的鼠標滾動並保持背景

使用下面的解決方案,如下面提及的是能夠通過以下的解決方案,達到了預期

<div style='overflow:hidden; width:200px;'> 
     <div style='overflow:scroll; width:217px'> 
      My mousewheel scrollable content here.... 
     </div> 
    </div> 

鏈接:Remove HTML scrollbars but allow mousewheel scrolling

,我現在已經是問題孩子DIV中,有是一個表與替代的顏色和樣式,我想保持背景。目前,使用上述解決方案,17px的滾動條區域爲空,看起來有人已經擦掉了滾動條。問題是:

(a)如何保持背景? (b)我可以將垂直滾動條的寬度減小到1px,這樣它就只顯示爲一條細線,用戶甚至不會注意到滾動條的存在。

回答

0
I tried a different solution using jQuery to avoid the background problem  

    //My page is split into 2 sections div1 and div2 
    //div1 - Div on Left Hand Side 
    //div2 - Div on Right Hand Side 
    //On scrolling mouse in either of the divs, the other div should move up/down 

    Tried the below code and it works. Hope this helps someone  


    $('#div1').bind('mousewheel', function(event, delta, deltaX, deltaY) { 

    console.log(delta, deltaX, deltaY); 

     var panelPos=$('#div2').scrollTop(); 
    $('#div2').scrollTop(panelPos - (deltaY * 30)); 
    $('#div1').scrollTop($('#div2').scrollTop()); 

    });