Html 标签中的换行符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2915983/
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
Line break in Label
提问by Piyush
when i m writing a long sentence in label without line break then it does wrap automatically. i m putting that label in tag. how can i wrap that long sentence.
当我在没有换行符的情况下在标签中写一个长句子时,它会自动换行。我把那个标签放在标签里。我怎么能把这么长的句子包装起来。
采纳答案by Pranay Rana
create style sheet like this "
创建这样的样式表“
.label { word-wrap: break-word }
and assign to you label
并分配给您的标签
check the link for more detail : http://www.css3.com/css-word-break/
检查链接以获取更多详细信息:http: //www.css3.com/css-word-break/
回答by Dustin Laine
Unclear, but you can force a line break by adding a <br />
in it.
不清楚,但您可以通过<br />
在其中添加 a 来强制换行。
<label>Some long long long long long long<br /> long long long label</label>
回答by sitesbyjoe
I'd hesitate to use the CSS3 solution without some kind of IE fallback.
如果没有某种 IE 回退,我会犹豫是否使用 CSS3 解决方案。
You need to add the following CSS to your label:
您需要将以下 CSS 添加到您的标签中:
label { display: block; width: 100px; }
Then change the width to the width you'd like your label to be and the sentence will wrap within the space.
然后将宽度更改为您希望标签的宽度,句子将在空间内换行。
By default a label has inline display which makes width control difficult.
默认情况下,标签具有内联显示,这使得宽度控制变得困难。
If you still need the label to be inline with your input field, float the label.
如果您仍然需要标签与输入字段内联,请浮动标签。