jquery - CSS/jQuery - 使用 css 和 jQuery 换行

标签 jquery css

我正在使用隐藏文本的脚本,并且仅当用户将鼠标悬停在字段中时才会显示该文本

但是,我无法中断文本行,我该怎么做?

我正在使用 .net 和 razor

屏幕截图

Without Mouse Hover

With Mouse Hover in the field

查看

<tr>
                <td colspan="10" style="padding-bottom: 0px;">
                    <div id="collapse_@(item.Id)" class="collapse in">
                        <table class="table">
                            <thead class="thead-light">
                                <tr>
                                    <th colspan="11">
                                        Observações
                                    </th>
                                </tr>
                                <tr>
                                    <td colspan="6">

                                        <p class="txt-note">
                                            @Html.DisplayFor(modelItem => item.Observacao)
                                        </p>
                                    </td>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </td>
            </tr>

jQuery

function adjustFieldNote() {
    $('.txt-note').on('mouseover', function (e) {
        var $el = $(this);
        $el.addClass("open");

    });

    $('txt-note').on('mouseout', function (e) {
        var $el = $(this);
        $el.delay(1500).removeClass("open");
    })
}

CSS

.txt-note {
    width: 800px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break:break-all
}



.open{
    white-space: normal !important;
    overflow: unset !important;
    text-overflow: initial !important;
    width: 100% !important;
    height: 100% !important;
    word-break: break-all
}

最佳答案

使用这个 CSS 片段:

.txt-note {
    width: 800px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    word-wrap: break-word;
}

关于jquery - CSS/jQuery - 使用 css 和 jQuery 换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60113564/

相关文章:

Javascript 鼠标步进事件

javascript - 动态选择 Javascript DOM 元素

javascript - 为 :checked 之前的所有元素设置样式

javascript - 如何在 Angular JS 中包含模块级 CSS

javascript - 如何使用 jQuery 调整 DIV 行的大小

jquery - 如果使用jquery在一个页面中存在多个表单,如何提交特定表单

Javascript 操作 HTML 字符串

javascript - 使用 JS 更改 svg 的 css 填充

java - java jsoup html 提取数据

html - 事件 :firstchild styling