gpt4 book ai didi

asp.net - div 溢出

转载 作者:行者123 更新时间:2023-11-28 18:10:09 26 4
gpt4 key购买 nike

我正在使用 asp.net。我正在尝试修复 div 的高度。我将所有数据隐藏在溢出中。这是我的代码示例:

    <div id="Content" style="height: 90px !important; overflow: hidden; text-decoration: none;
text-overflow: ellipsis; display: block; white-space: nowrap;">
abcd<br />
efgh<br />
ijkl<br />
mnop<br />
qrst<br />
uvwx<br />
</div>

我想显示 ijkl 之前的内容,我想在溢出部分显示 More... 这是一个演示:

 abcd
efgh
ijkl
more..

但我无法获得此输出。我想给内联CSS。请帮助我。

怀念

最佳答案

你可以在 div 下面添加标签,像这样:

<div id="Content" style="height: 90px !important; overflow: hidden; text-decoration: none">
abcd<br />
efgh<br />
ijkl<br />
mnop<br />
qrst<br />
uvwx
</div>
<label style="display: none">more..</label>

当文本像这样溢出时,使用 jquery 来玩弄它的可见性:

$(function(){
if($('#Content')[0].scrollHeight > $('#Content').height())
$('#overflowLabel').show();
});

jsFiddle

关于asp.net - div 溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18826691/

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