我有以下情况。容器c
具有固定属性。它始终是100%的高度。不动。
容器b
具有动态高度。
容器a
(正文)根本无法显示滚动条。
问题:如何强制body
中的滚动条消失,但容器b
中的滚动条出现?谢谢!
.a {
display: flex;
height: 300px;
}
.b,
.c {
width: 50%;
}
.b {
background: blue;
height: 600px;
overflow-y: scroll;
}
.c {
background: green;
height: 300px;
position: fixed;
right: 0;
}
<div class='a'>
<div class='b'>
</div>
<div class='c'>
</div>
</div>
答案 0 :(得分:1)
归功于SirExotic
您的.b容器需要的内容超过b的高度才能激活滚动条。
body {
overflow-y: hidden; /* added */
}
.a {
display: flex;
height: 300px;
}
.b,
.c {
width: 50%;
}
.b {
background: blue;
height: 600px;
overflow-y: scroll;
}
.b-content {
min-height: 800px;
}
.c {
background: green;
height: 300px;
position: fixed;
right: 0;
}
<div class='a'>
<div class='b'>
<div class="b-content">
here I am
</div>
</div>
<div class='c'>
</div>
</div>