不知怎的,我无法让滚动条工作。
https://jsfiddle.net/rafuw31g/2/
如果以某种方式复制粘贴#scrollable
内容,则灵活内容溢出浏览器高度和#bottom
消失。
#sidebar {
box-shadow: 1px 0 0 0 rgb(25, 25, 25);
background-color: rgb(45, 45, 45);
position: fixed;
width: 250px;
display: flex;
min-height: 100%;
flex-direction: column
}
#sidebar > header {
border-bottom: 1px solid rgb(25, 25, 25);
background: url('http://puu.sh/prf5M/2b91e2fea8.png') no-repeat 0 0 transparent;
height: 100px;
width: 250px;
}
#sidebar > header a {
display: block;
height: 100%;
width: 100%;
cursor: pointer;
}
#sidebar > section#top {
background-color: rgb(25, 25, 25);
height: 35px;
width: 100%;
line-height: 35px;
text-align: center;
}
#sidebar > section#top::after {
display: block;
content: '';
clear: both;
}
#sidebar > section#top a {
float: left;
cursor: pointer;
width: 125px;
color: rgb(175, 175, 175);
text-decoration: none;
}
#sidebar > section#top a:hover {
background-color: rgb(33, 33, 33);
color: rgb(200, 200, 200);
}
#sidebar > section#top a:first-child,
#sidebar > section#top a:first-child:hover {
background-color: rgb(45, 45, 45);
color: rgb(225, 225, 225);
cursor: default;
}
#sidebar > section#scrollable {
overflow-x: hidden;
overflow-y: hidden;
flex: 1;
min-height: 50px;
}
#sidebar > section#scrollable:hover {
overflow-y: scroll;
}
#sidebar > section#scrollable a {
display: block;
height: 50px;
line-height: 50px;
}
#sidebar > section#bottom {
position: relative;
width: 100%;
bottom: 0;
border-top: 1px solid rgb(25, 25, 25);
text-align: center;
padding: 10px 0;
}
<div id="sidebar">
<header>
<a></a>
</header>
<section id="top">
<a>Tab 1</a>
<a>Tab 2</a>
</section>
<section id="scrollable">
<a>
<span>Lorem ipsum dolor sit amet</span>
</a>
</section>
<section id="bottom">
<a>Impressum</a>
</section>
</div>
答案 0 :(得分:1)
您可以将容器添加到可滚动区域:
<section id="scrollable">
<div class="content">
...
风格:
#sidebar > section#scrollable {
flex: 1;
min-height: 50px;
position: relative;
}
#sidebar > section#scrollable:hover > .content {
overflow-y: auto;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
<强> jsFiddle 强>
答案 1 :(得分:0)
我认为您需要做的就是为可滚动部分添加一些最大高度。这样div就知道滚动器何时启动。
#sidebar > section#scrollable {
overflow-x: hidden;
overflow-y: hidden;
flex: 1;
min-height: 50px;
max-height: 100px;
}