asp.net - div 溢出

标签 asp.net css html

我正在使用 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/

相关文章:

asp.net - 使用 SqlConnection 和 VB.NET 创建 ASP.NET 联合提要

html - Bootstrap 下拉列表 :hover

html - 悬停在一个 div 上并显示另一个 div

html - 使 float 社交图标垂直

javascript - 如何在 jquery 中通过其 href 获取元素?

.net - 如何在asp.net 中加密查询字符串?

ASP.NET 入口点?

asp.net - 我的数据库没有与我的 MVC 应用程序一起部署

javascript - 这个JS可以用纯CSS写吗?

html - CSS - 具有两行和无限宽度的可滚动水平 div?