Html 文本未包装在标签标签中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1710590/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Text not wrapping in label tag
提问by timewarpagain
How do you wrap text in a tag?
你如何在标签中包装文本?
I have set the width however text just continues to overflow the element.
我已经设置了宽度,但是文本只是继续溢出元素。
Thanks
谢谢
回答by Bob
Give this a try
试试这个
<div style="white-space:wrap">Some long text........</div>
回答by Justin Lucas
Is the tag floated?
-if so then add this after the text <div style='clear:both; width:100%; height:1px;'></div>
标签是浮动的吗?- 如果是,则在文本后添加此内容<div style='clear:both; width:100%; height:1px;'></div>
Please show us the code so we can see exactly what your doing.
请向我们展示代码,以便我们准确了解您在做什么。
回答by matthewsheets
To anyone still struggling, be sure to check and see if you've set a line-height value on the font in question: it could be overriding the word wrap, even if you've done it correctly.
对于仍在苦苦挣扎的任何人,请务必检查您是否已在相关字体上设置了行高值:它可能会覆盖自动换行,即使您已正确完成。
回答by matthewsheets
You may not need to do anything to get this effect in a basic div, but you can try "word-wrap: break-word" in the style of your element. For example, try resizing a window with:
您可能不需要做任何事情来在基本 div 中获得这种效果,但是您可以尝试在元素样式中使用“word-wrap: break-word”。例如,尝试使用以下命令调整窗口大小:
<div style='word-wrap: break-word'>Here's a div with a ton, a ton, a ton, a ton, a ton, a ton, a ton, a ton, a ton, a ton, a ton, a ton, a ton, a ton, a ton of text.</div>
Check out this JS Fiddle to try it out http://jsfiddle.net/zCQFb/(from Michael's answer: https://stackoverflow.com/a/7166571).
查看这个 JS Fiddle 来尝试一下http://jsfiddle.net/zCQFb/(来自 Michael 的回答:https: //stackoverflow.com/a/7166571)。