我有一个 asp:label 必须适合它的父容器
问题是有时文本是一个连续的字符序列,没有空格。
我正在寻找 CSS 行为来在单词太长时断开单词,但不会断开可以转移到它下面的行的小单词。
这是我最初拥有的:
<asp:Label ID="lblTextComments" runat="server"></asp:Label>
这会产生:
some normal text that
breaks onto a new line
但这发生在一个长词上:
someverylongtextwithoutanywhitespaceatalldoesnotcausealinebreaktohappen
这会在网页外运行。
我使用了这个 CSS 样式解决方案:
<asp:Label ID="lblTextComments" runat="server" Style="word-wrap: normal; word-break: break-all;" ></asp:Label>
这正确地打破了长词:
someverylongtextwithoutanywh
itespaceatalldoesnotcauseali
nebreaktohappen
但这打破了我希望移到下一行的小词:
some normal text tha
t breaks onto a new line
最佳答案
试试这个 CSS:
word-wrap: break-word;
关于c# - asp :label text using word-break on only long words? 上的断行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38839501/