gpt4 book ai didi

javascript - 使用 CSS 显示所有字符的 contenteditable 单行

转载 作者:行者123 更新时间:2023-11-28 06:05:15 25 4
gpt4 key购买 nike

如果用户聚焦显示所有字符而不 chop 的 div,我需要 chop 字符。

我们归档了相同的,但是我们得到了多行

但我需要用户关注 div 需要在一行中显示所有字符

DEMO

HTML:

这应该有效这应该有效这应该有效这应该有效这应该有效这应该有效这应该有效这应该有效这应该有效这应该有效这应该有效

CSS:

 .single-line {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: inline-block;
vertical-align: top;
}

[contenteditable="true"].single-line {
white-space: nowrap;
width:200px;
overflow: hidden;
}
[contenteditable="true"].single-line br {
display:none;

}
[contenteditable="true"].single-line * {
display:inline;
white-space:nowrap;
}


.single-line:focus {
white-space:normal;
}

最佳答案

大概是这样的?

See this fiddle

我在容器上添加了一个固定的 height 并禁用了焦点上的 text-overflow 属性。

.single-line:focus {
text-overflow: inherit;
}

关于javascript - 使用 CSS 显示所有字符的 contenteditable 单行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36500317/

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