Html CSS 2.1:将文本包裹在 Div 中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12388088/
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
CSS 2.1: Wrap Text Inside Div
提问by LCJ
I have HTML and CSS as shown in http://jsfiddle.net/Lijo/Ydjde/
我有 HTML 和 CSS,如http://jsfiddle.net/Lijo/Ydjde/所示
The problem is the text inside div is not confined to the div. It breaks the div and write. How can we wrap the text inside the div itself with following features?
问题是 div 内的文本不限于 div。它打破了 div 并写入。我们如何使用以下功能将文本包裹在 div 本身中?
? The full text will be readable
? 全文将可读
? It will not break the div
? 它不会破坏 div
Is there a way to use it in CSS 2.1? I believe word-wrap is CSS 3.0 feature.
有没有办法在CSS 2.1 中使用它?我相信自动换行是 CSS 3.0 的特性。
Note: I have widthdefined as width:100px; and width:30px; for the first and second divs
注意:我将宽度定义为 width:100px; 和宽度:30px;对于第一个和第二个 div
Note: The span is generated from ASP.Net Label control. Hence we cannot change/replace the span. The problem is to be resolved using CSS.
注意:span 是从 ASP.Net Label 控件生成的。因此我们无法更改/替换span。该问题将使用 CSS 解决。
<span id="detailContentPlaceholder_Label1">25123456789</span>
Reference:
参考:
回答by Roddy of the Frozen Peas
word-wrap: break-word;
is your friend. See your updated JSFiddle.
word-wrap: break-word;
是你的朋友。查看您更新的 JSFiddle。
回答by Roman
do you mean word-wrap: break-word
?
你的意思是word-wrap: break-word
?
(edit: oops, didn't see the other answer)
(编辑:哎呀,没有看到其他答案)
回答by immayankmodi
I have found something strange here about word-wrap
only works with width
property of css properly.
我在这里发现了一些奇怪的东西,word-wrap
它只适用于width
css 的属性。
here is a working demothat i have prepared about it.
这是我准备的一个工作演示。
I know its too late but it could help others!
我知道为时已晚,但它可以帮助其他人!
回答by ram
you add change width:35px then work properly
.fixedColumnValue{
width:auto;
}