gpt4 book ai didi

css - 不需要滚动时移除滚动条

转载 作者:行者123 更新时间:2023-11-28 09:20:52 25 4
gpt4 key购买 nike

由于下面的 CSS,我有一个带有滚动条的 div。但是,当不需要滚动时,该栏仍然存在。没有 slider /箭头,但只有一个空栏。有没有办法只在内容溢出时显示栏?谢谢。

#id{
overflow: -moz-scrollbars-vertical;
overflow-x: hidden;
overflow-y: scroll;
}

最佳答案

使用

overflow: auto;

那么只有真正溢出了才会显示overflow

auto The behavior of auto isn’t specified in any detail in the CSS2.1 specification. In existing implementations it provides scrollbar(s) when necessary, but it doesn’t show scrollbars unless the content overflows the element’s box.

http://reference.sitepoint.com/css/overflow

关于css - 不需要滚动时移除滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6663502/

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