gpt4 book ai didi

html - 将滚动条放在 div 之外并自动溢出

转载 作者:技术小花猫 更新时间:2023-10-29 11:44:45 25 4
gpt4 key购买 nike

我有一个带有 overflow:auto; 的小 div,但是当滚动条出现时,它覆盖了大量的 div。这可以通过使用 overflow:scroll; 来避免,但是当没有溢出时,你会得到难看的褪色滚动条。有没有办法在不使用 overflow:scroll; 的情况下将滚动条放在 div 之外?谢谢。

这是一个演示jsfiddle

.alphabet{ display:inline-block;
overflow-y:auto;
overflow-x:hidden;
border:1px solid;
height:50;
}

<div class = "alphabet">abcdefgh<br>
ijklmnop<br>
qrstuvwx
</div>

最佳答案

如果可以选择在 .alphabet 周围使用容器元素,你可以在上面设置垂直滚动。我添加了 <hr>伪造一个始终可见的底部边框,该边框也不会位于滚动条下方。

HTML:

<div class="container">
<div class="alphabet">
abcdefgh<br />
abcdefgh<br />
abcdefgh<br />
abcdefgh<br />
</div>
</div>
<hr>

CSS:

.container{
overflow-y:auto;
overflow-x:hidden;
height:50px;
width:100px;
}

.alphabet{
width:100%;
overflow:visible;
box-sizing:border-box;
border:1px solid;
border-bottom:0;
}

hr{
margin:0;
height:0;
width:85px;
border:0;
border-bottom:1px solid;
}

带内边框:http://jsfiddle.net/Q32gG/1/

如果您实际上并不关心边框内显示的滚动条,您可以删除 <hr>并为 .container 添加一个完整的边框而是 ( http://jsfiddle.net/V3MbV/3/ )。

关于html - 将滚动条放在 div 之外并自动溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16306322/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com