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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 02:47:39  来源:igfitidea点击:

CSS 2.1: Wrap Text Inside Div

htmlcss

提问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>

enter image description here

在此处输入图片说明

Reference:

参考:

  1. Word-wrap in an HTML table
  2. CSS word-wrapping in div
  3. CSS3 word-wrap Property
  1. HTML 表格中的自动换行
  2. div中的CSS自动换行
  3. CSS3 自动换行属性

回答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

http://jsfiddle.net/PhRKh/

http://jsfiddle.net/PhRKh/

(edit: oops, didn't see the other answer)

(编辑:哎呀,没有看到其他答案)

回答by immayankmodi

I have found something strange here about word-wraponly works with widthproperty of css properly.

我在这里发现了一些奇怪的东西,word-wrap它只适用于widthcss 的属性。

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;
    }