我正在创建一个带有滚动侧边栏的应用程序,但是当我使用Firefox时它的行为有点奇怪:如果鼠标在侧边栏中较低,侧边栏中的内容会在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的链接:https://jsfiddle.net/threerightangles/os1b48ou/
答案 0 :(得分:0)
尝试将overflow-y: scroll
上的overflow-y: auto
更改为#scrollable
:
<强> 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>