gpt4 book ai didi

jquery - 即使没有可滚动的内容,也会出现 css 溢出滚动条

转载 作者:技术小花猫 更新时间:2023-10-29 12:36:13 26 4
gpt4 key购买 nike

我像下面的代码一样使用 overflow:scroll,我遇到的问题是即使没有文本,滚动条仍然显示。
w3schools 上的演示:http://www.w3schools.com/cssref/tryit.asp?filename=trycss_overflow你会看到,即使你不能水平滚动(向左或向右),仍然有一个滚动条。如果没有任何内容可滚动到,我试图将它放在滚动条不出现的地方。希望这是有道理的

<style type="text/css">
div.scroll {
background-color: #00FFFF;
width: 100px;
height: 100px;
overflow: scroll;
}
</style>
<p>overflow:scroll</p>
<div class="scroll">You can use the overflow property when you want to have better control of the layout. The default value is visible.</div>

最佳答案

我认为您正在寻找 overflow: auto

Mozilla's Documentation on Overflow

The overflow CSS property is shorthand for the overflow-x and overflow-y properties, and specifies what to do when content is too large to fit in its block formatting context.

The options include clipping, showing scrollbars, or displaying the content flowing out of its container into the surrounding area.

自动

Depends on the user agent. If content fits inside the padding box, it looks the same as visible, but still establishes a new block-formatting context. Desktop browsers like Firefox provide scrollbars if content overflows.

关于jquery - 即使没有可滚动的内容,也会出现 css 溢出滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10196008/

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