左对齐textarea的文本

时间:2015-06-05 06:17:14

标签: javascript html css html5

我没什么问题,但我无法解决,所以我有一个textarea,我想对齐左边的文本,我的代码是:

 <textarea
     rows="3"
     cols="25"
     id="{{ form_add_gift.description_article.name }}"
     name="{{ form_add_gift.description_article.name }}"
     style="padding: 0px !important; margin: 0px !important;text-align: left;"
     class="form-control"
     required="required">
     {{ form_add_gift.description_article.value|trim }}
</textarea>

texarea看起来像这样: 请帮我!! Thx提前

enter image description here

7 个答案:

答案 0 :(得分:3)

这只是因为您的_______{{ form_add_gift.description_article.value|trim }}在开头包含太多空格。

只需删除空白区域。

答案 1 :(得分:2)

在为文本区域提供输入的同时给予空间,没有css更改需要你的案例尝试:

<textarea
     rows="3"
     cols="25"
     id="{{ form_add_gift.description_article.name }}"
     name="{{ form_add_gift.description_article.name }}"
     style="padding: 0px !important; margin: 0px !important;text-align: left;"
     class="form-control"
     required="required">{{ form_add_gift.description_article.value|trim }}
</textarea>

答案 2 :(得分:1)

<强>转换

<textarea
 rows="3"
 cols="25"
 id="{{ form_add_gift.description_article.name }}"
 name="{{ form_add_gift.description_article.name }}"
 style="padding: 0px !important; margin: 0px !important;text-align: left;"
 class="form-control"
 required="required">
 {{ form_add_gift.description_article.value|trim }}
</textarea>

<textarea rows="3" cols="25" id="{{ form_add_gift.description_article.name     }}" name="{{ form_add_gift.description_article.name}}" style="padding: 0px     !important; margin: 0px !important;text-align: left;" class="form-control"     required="required">{{ form_add_gift.description_article.value|trim }</textarea>

基本上,您需要做的是在标记结束后删除额外的换行符和空格,即

<textarea>your text</textarea>

答案 3 :(得分:1)

删除textarea中的空格,或使用white-space: normal;作为一种智能方法来避免textarea中的空格。

  

删除了空格

 <textarea
     rows="3"
     cols="25"
     id="{{ form_add_gift.description_article.name }}"
     name="{{ form_add_gift.description_article.name }}"
     style="padding: 0px !important; margin: 0px !important;text-align: left;"
     class="form-control"
     required="required">{{ form_add_gift.description_article.value|trim }}
</textarea>
  

未删除空格,添加空格:正常;

 <textarea
     rows="3"
     cols="25"
     id="{{ form_add_gift.description_article.name }}"
     name="{{ form_add_gift.description_article.name }}"
     style="padding: 0px !important; margin: 0px !important;text-align: left;white-space: normal;"
     class="form-control"
     required="required">
     {{ form_add_gift.description_article.value|trim }}
</textarea>

答案 4 :(得分:1)

试试这个:

<textarea name="{{ form_add_gift.description_article.name }}" id="{{ form_add_gift.description_article.name }}" class="form-control" required="required"  rows="3" cols="25" style="padding: 0px ;  margin: 0px; align: left;"  >

      {{ form_add_gift.description_article.value|trim }}
</textarea>     

答案 5 :(得分:1)

从textarea值的赋值中删除多余的空格和换行符,如:

<textarea>{{ form_add_gift.description_article.value|trim }}</textarea>

答案 6 :(得分:0)

尝试删除<textarea>{{ form_add_gift.description_article.value|trim }}</textarea>之间的空格,如下面的代码。

<textarea
rows="3"
cols="25"
id="{{ form_add_gift.description_article.name }}"
name="{{ form_add_gift.description_article.name }}"
style="padding: 0px !important; margin: 0px !important;text-align: left;"
class="form-control"
required="required">{{ form_add_gift.description_article.value|trim }}</textarea>