简体   繁体   English

标签文本的自动换行在文本区域

[英]Word-wrap of Label text in text-area

I want to re-size the label of a text-area in format shown in the picture.I"m trying to do worp using paragraph tag but it is not happening.. 我想以图片中显示的格式重新调整文本区域的标签。我正在尝试使用段落标签来做worp,但它没有发生..

my code.... 我的代码......

 <label for="qual">This is the format i want the text-area to be displayed:</label>  
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 <textarea id="qual" rows="5" cols="50" style="resize:none" placeholder="Description and Qualification"></textarea><br><br>

Desired Output.. 期望的输出..

照片png图像

style="max-width: 140px; word-wrap: break-word"

place this in your label tag and adjust the max-width or min-width to your needs. 将其放在标签标签中,并根据需要调整最大宽度或最小宽度。 heads up doesn't work in IE 抬头在IE中不起作用

Here is the Solution . 这是解决方案

The HTML: HTML:

<label for="qual" class="abc">This is the format i want the text-area to be displayed:</label>
<textarea id="qual" rows="5" cols="50" style="resize:none" placeholder="Description and Qualification"></textarea>

The CSS: CSS:

.abc{float:left; width:125px; text-align:left; margin-right:30px;}

If you dont want to create a class, you can apply the styles on label in the CSS. 如果您不想创建类,可以在CSS中的label上应用样式。

Hope this helps. 希望这可以帮助。

Try white-space: normal; 尝试white-space: normal;

For more details visit http://www.w3schools.com/cssref/pr_text_white-space.asp 有关更多详细信息,请访问http://www.w3schools.com/cssref/pr_text_white-space.asp

Something like this: 像这样的东西:

label { 
  float: left; 
  width:120px;
  padding:10px 30px;
  font-weight:bold;
}

Demo 演示

In the block of your HTML add: 在HTML的块中添加:

<style>
  label { padding:5px; font-weight:bold; float:left; width:150px; }
</style>

The style settings above will also replace the spacing: 上面的样式设置也将替换间距:

<label for="qual">This is the format i want the text-area to be displayed:</label>  
<textarea id="qual" rows="5" cols="50" style="resize:none" placeholder="Description and Qualification"></textarea>

You want to style the label and textarea elements in a self-contained, bullet-proof manner. 您希望以自包含,防弹方式设置labeltextarea元素的样式。

I suggest the following HTML: 我建议使用以下HTML:

<div class="wrap">
    <label for="qual">This is the format...to be displayed:</label>
    <textarea id="qual" rows="5" cols="50" style="resize:none" 
              placeholder="Description and Qualification"></textarea>
</div>

with the following CSS: 使用以下CSS:

.wrap {
    outline: 1px dotted blue; /* Just for demonstration... */
    overflow: auto;
}

.wrap label {
    outline: 1px dashed blue;
    float:left;
    width: 10em;
    margin-right: 1.00em;
}

Define a parent container div.wrap to hold the two child elements and specify overflow: auto to generate a new block formatting context. 定义父容器div.wrap以保存两个子元素,并指定overflow: auto以生成新的块格式化上下文。

You want to do this to make sure that the floated label field does not interfere with any other adjacent elements that may be in the page or form. 您希望这样做以确保浮动标签字段不会干扰页面或表单中可能包含的任何其他相邻元素。 This may be important if you are building a responsive design. 如果您正在构建响应式设计,这可能很重要。

The <label> field is floated left and you must specify a suitable width. <label>字段向左浮动,您必须指定合适的宽度。 You can also apply margins, background color or images, padding as needed to create the design that you need. 您还可以根据需要应用边距,背景颜色或图像,填充以创建所需的设计。

Fiddle: http://jsfiddle.net/audetwebdesign/2sTez/ 小提琴: http//jsfiddle.net/audetwebdesign/2sTez/

Try using textWrap="true" attribute in the Label tag 尝试在Label标签中使用textWrap =“true”属性

for example: 例如:

<Label text="A very long text like this should be wrapped to next line"  textWrap="true"></Label>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM