gpt4 book ai didi

javascript - 溢出:隐藏但让内容自动滚动

转载 作者:行者123 更新时间:2023-11-30 13:26:17 25 4
gpt4 key购买 nike

我有一个 div,其中的内容通过查询的 append() 定期附加到它。随着内容越来越长,最终会溢出div。我不希望在溢出时出现滚动条,但仍然让内容向上滚动以显示下面的新内容。

这可能吗?当我使用 overflow-x: hidden 时,没有出现滚动条,但内容被隐藏了。

最佳答案

如果容器的大小是固定的,您可以将内容放在绝对定位的包装内,如下所示:

<div class="container">
<div class="wrap">
<p>bah</p>
</div>
</div>

和CSS:

.container {
y-overflow: hidden;
position: relative;
height: 200px;
width: 200px;
}

.wrap {position:absolute; bottom: 0; left:0;right:0;
}

http://jsfiddle.net/sXGd9/

关于javascript - 溢出:隐藏但让内容自动滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8342081/

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