【发布时间】:2023-04-08 02:10:01
【问题描述】:
背景
我有一个固定宽度和高度的不可滚动的 div。 这是一个 JSFiddle:https://jsfiddle.net/Naibaf/47fm4pvf/2/
目标
如果不是前面的字符串,我想尽可能多地显示底部字符串。
推理和问题
你应该问自己:为什么?我正在尝试显示news-alert-like-bar,但我将我的 div 的内容与setInterval() 连接起来,这将使其快速溢出。
在我看来,jQuery 的 .scrollTop() 像这里:http://jsfiddle.net/2WpQf/1/ 是不合适的,因为我希望我的 div 不能滚动。 CSS overflow 也是如此。
有人知道怎么做吗?
HTML
<p>How to make the bottom of a string visible within the boundaries of a div and NOT show or hide the top part?</p>
<p>The opposite of what I want:
</p>
<div class="hidden">You can use the overflow property when you want to have better control of the layout. The default value is visible.</div>
CSS
div.hidden {
background-color: #00FF00;
width: 100px;
height: 100px;
overflow: hidden;
}
【问题讨论】:
-
我不清楚...您想要固定尺寸,但显示所有内容并且不使用滚动?
-
固定尺寸,无滚动,但仅显示适合 div 的底部内容。
-
喜欢这个jsfiddle.net/47fm4pvf/3 ?
-
就是这样!非常感谢。我现在怎么给你信用?
-
一般我们使用 div.hidden { background-color: #00FF00;宽度:100px;高度:100px;溢出-y:滚动; }