2017-01-22 41 views
0

我使用滾動邊欄創建了一個應用程序,但是當我使用Firefox時,它的行爲有些奇怪:邊欄中的內容消失在div頂部以下,如果鼠標較低邊欄,並且當鼠標位於邊欄的頂部時會正確消失。在Firefox中奇怪的滾動邊欄行爲

under Firefox, the top of sidebar disappears below the top of the div when I scroll with the mouse in the lower part of the div, although it behaves correctly when the mouse is in the top part of the div

這不是世界末日,但我寧願我的應用程序並不奇怪行爲與Firefox用戶。

這裏的HTML:

<div id="header"> 
    <h1>Header</h1> 
</div> 
<div id="fixed-body"> 
    Test 
</div> 
<div id="scrollable"> 
    <div id="menu-header"> 
    Menu 
    </div> 
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vitae mauris in lacus vestibulum facilisis non at mauris. 
    </p> 
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vitae mauris in lacus vestibulum facilisis non at mauris. 
    </p> 
</div> 

而CSS:

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

#header { 
    position: fixed; 
    left: 0; 
    top: 0; 
    height: 10%; 
    width: 100%; 
    background-color: #DDFFDD; 
    color: #005500; 
} 

h1 { 
    font-size: 2em; 
    margin: 0; 
    padding: 5px; 
    } 

    #fixed-body { 
    position: fixed; 
    top: 10%; 
    left: 0; 
    background-color: #AAAAFF; 
    width: 75%; 
    height: 90%; 
    } 

    #scrollable { 
    height: 100%; 
    width: 25%; 
    margin-left: 75%; 
    margin-top: 10%; 
    padding: 0; 
    overflow-y: scroll; 
    } 

    #menu-header { 
    width: 90%; 
    margin: 0 5%; 
    padding: 3px; 
    background-color: #F80; 
    font-size: 1.8em; 
    font-weight:bold; 
    } 

    p { 
    margin: 10px; 
    font-size: 1.4em; 
    } 

和鏈接到的jsfiddle:上#scrollablehttps://jsfiddle.net/threerightangles/os1b48ou/

回答

0

嘗試改變overflow-y: scrolloverflow-y: auto

External JSFiddle here

body, 
 
html { 
 
    margin: 0; 
 
    padding: 0; 
 
    width: 100%; 
 
    height: 100%; 
 
} 
 
#header { 
 
    position: fixed; 
 
    left: 0; 
 
    top: 0; 
 
    height: 10%; 
 
    width: 100%; 
 
    background-color: #DDFFDD; 
 
    color: #005500; 
 
} 
 
h1 { 
 
    font-size: 2em; 
 
    margin: 0; 
 
    padding: 5px; 
 
} 
 
#fixed-body { 
 
    position: fixed; 
 
    top: 10%; 
 
    left: 0; 
 
    background-color: #AAAAFF; 
 
    width: 75%; 
 
    height: 90%; 
 
} 
 
#scrollable { 
 
    height: 100%; 
 
    width: 25%; 
 
    margin-left: 75%; 
 
    margin-top: 10%; 
 
    padding: 0; 
 
    overflow-y: auto; 
 
} 
 
#menu-header { 
 
    width: 90%; 
 
    margin: 0 5%; 
 
    padding: 3px; 
 
    background-color: #F80; 
 
    font-size: 1.8em; 
 
    font-weight: bold; 
 
} 
 
p { 
 
    margin: 10px; 
 
    font-size: 1.4em; 
 
}
<div id="header"> 
 
    <h1>Header</h1> 
 
</div> 
 
<div id="fixed-body"> 
 
    Test 
 
</div> 
 
<div id="scrollable"> 
 
    <div id="menu-header"> 
 
    Menu 
 
    </div> 
 
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vitae mauris in lacus vestibulum facilisis non at mauris. 
 
    </p> 
 
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vitae mauris in lacus vestibulum facilisis non at mauris. 
 
    </p> 
 
</div>