文本区域将第一行文本居中,我希望它左对齐
我在表单中有一个简单的文本区域,由于某种原因,当我单击文本区域开始输入时,它会将第一行居中。我可以按退格键,直到它在文本区域的开头对齐,但我不知道为什么要这样做。我用谷歌搜索过,似乎找不到这样做的原因。这是我的jsfiddle:
我尝试过文本对齐:left 在很多地方(内联 HTML 和 CSS),它似乎没有改变任何东西。看来这应该是一个简单的修复,感谢您的帮助。
I've got a simple textarea in a form and for some reason when I click in the textarea to begin to type, it centers the first line. I can hit backspace until it lines up at the start of textarea but I don't know why it's doing that. I've Googled and can't seem to find a reason why it would do this. Here is my jsfiddle for it:
I've tried text-align:left in numerous places (inline HTML and CSS) and it doesn't seem to change anything. It seems like it should be a simple fix, thanks for the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它不是居中的,它只是具有一系列空格字符的默认值。
将
紧跟在开始标记之后,而不是用空格填充。
It isn't centred, it just has a default value of a series of space characters.
Put
</textarea>
immediately after the start tag instead of filling it with whitespace.文本区域的默认内容是其标签之间的内容。您的源代码类似于:
因此文本区域的初始值是换行符和用于缩进的空格 - 您可以退格的字符。
要摆脱它们,请立即关闭标签:
旁白:您想要的表单布局可能应该使用表格来完成 - 至少在各种闪亮的新 CSS3 布局得到更好的支持之前。您避免使用它们实际上使所有
的代码可读性降低。The default content of a text area is the content between its tags. Your source has something like:
so the initial value of the text area is the newline and the spaces used for indentation – the characters you can backspace over.
To get rid of them, close the tag immediately:
Aside: the kind of form layout you're going for should probably be done using tables – at least until the various shiny new CSS3 layouts are better supported. Your avoiding them actually made the code less readable what with all the
<br/>
s.