文本区域将第一行文本居中,我希望它左对齐

发布于 2024-12-26 03:26:57 字数 290 浏览 2 评论 0原文

我在表单中有一个简单的文本区域,由于某种原因,当我单击文本区域开始输入时,它会将第一行居中。我可以按退格键,直到它在文本区域的开头对齐,但我不知道为什么要这样做。我用谷歌搜索过,似乎找不到这样做的原因。这是我的jsfiddle:

http://jsfiddle.net/4cVkn/

我尝试过文本对齐: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:

http://jsfiddle.net/4cVkn/

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼泪都笑了 2025-01-02 03:26:57

它不是居中的,它只是具有一系列空格字符的默认值。

紧跟在开始标记之后,而不是用空格填充。

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.

审判长 2025-01-02 03:26:57

文本区域的默认内容是其标签之间的内容。您的源代码类似于:

        <textarea name="bio">
        </textarea>

因此文本区域的初始值是换行符和用于缩进的空格 - 您可以退格的字符。

要摆脱它们,请立即关闭标签:

<textarea name="bio"></textarea>

旁白:您想要的表单布局可能应该使用表格来完成 - 至少在各种闪亮的新 CSS3 布局得到更好的支持之前。您避免使用它们实际上使所有
的代码可读性降低。

The default content of a text area is the content between its tags. Your source has something like:

        <textarea name="bio">
        </textarea>

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:

<textarea name="bio"></textarea>

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文