我的网站内容很长-因此网站必须可以垂直滚动。但是,页面底部还可以水平滚动div。不幸的是,该元素的水平滚动条直到用户向下滚动才可见。有什么办法可以始终在屏幕底部显示水平滚动条吗? Here是示例。
.container {
overflow-y: auto;
overflow-x: hidden;
}
.content {
background-color: lightblue;
height: 5rem;
}
.scrollable-content {
background-color: lightgreen;
height: 100vh;
overflow-x: auto;
width: 100%;
}
.wide-content {
width: 150vw;
}
<div class="container">
<div class="content">
Div which is not horizontally scrollable
</div>
<div class="scrollable-content">
Div which is horizontally scrollable
<div class="wide-content">
Some wide content
</div>
</div>
</div>
答案 0 :(得分:0)
我将scrollable-content
更改为此:
.scrollable-content {
background-color: lightgreen;
height: 89vh;
width: 1000%;
}
和正文:
body {
overflow: hidden;
}
我希望这会有所帮助
答案 1 :(得分:0)
您必须在CSS中添加一些-webkit-scrollbar
选择器,以每次显示滚动条。看下面的例子:
.scrollable-content::-webkit-scrollbar {
-webkit-appearance: none;
}
.scrollable-content::-webkit-scrollbar:horizontal {
height: 11px;
}
.scrollable-content::-webkit-scrollbar-thumb {
border-radius: 8px;
border: 2px solid white;
background-color: rgba(0, 0, 0, .5);
}
.scrollable-content::-webkit-scrollbar-track {
background-color: #fff;
border-radius: 8px;
}
.container {
overflow-y: auto;
overflow-x: hidden;
}
.content {
background-color: lightblue;
height: 5rem;
}
.scrollable-content {
background-color: lightgreen;
height: 30vh;
overflow-x: auto;
width: 100%;
}
.wide-content {
width: 150vw;
}
<div class="container">
<div class="content">
Div which is not horizontally scrollable
</div>
<div class="scrollable-content" style="width:500px; overflow-x:scroll; border:dotted 1px; white-space: nowrap;padding-bottom:10px;">
Div which is horizontally scrollable
<div class="wide-content">
Some wide content
</div>
</div>
</div>
我希望解决方案能像您想象的那样