HTML文本区域 - 光标从文本区域中心开始而不是顶部

7
我有一个HTML模板和CSS,渲染了一个文本域字段,但是当点击该字段时,光标从文本区域的中间开始,而不是我期望的左上角。
在IE中不会出现这种情况,但在Chrome和FF中会出现。我还会得到一个列出先前输入的值的列表,表明文本框样式已应用。
有人能指导我应该查找哪些CSS属性进行修改吗?
以下是HTML代码:
<input id="description" class="textarea" type="textarea" name="description" cols="70" rows="50">

以下是分配给文本区域的属性:

.standardForm .textarea {
    bottom: 0;
    height: 90px;
    left: 0;
    margin-bottom: 0.5em;
    right: 0;
}
custom.css (line 255)
.standardForm .textbox, .standardForm .textarea, .standardForm .submit, .standardForm .select {
    background: none repeat scroll 0 0 White;
    border: 1px dotted #AAAAAA;
}
custom.css (line 251)
.standardForm .textbox, .standardForm .textarea, .standardForm .select {
    font-size: 12px;
    overflow: hidden;
    padding: 7px;
    resize: none;
    width: 90%;
}
custom.css (line 250)
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, input, button, textarea {
    background: none repeat scroll 0 0 transparent;
    border: 0 none;
    font-size: 100%;
    font-weight: normal;
    margin: 0;
    outline: 0 none;
    padding: 0;
    text-decoration: none;
    vertical-align: baseline;
}

2
输入元素中没有“textarea”类型,而是一个文本区域元素。 - Andreas Köberle
4个回答

20

在textarea标记之间提供空格通常会导致不需要的空白。尝试没有空格的代码即可解决问题。

<textarea></textarea>

10

我认为使用

<textarea id="description" class="textarea" name="description" cols="70" rows="50"></textarea>

这应该能解决你的问题。


5

你的语法不正确。你不能在type属性中包含textarea值,而是像“roy”建议的那样使用<textarea></textarea>标签。


0
感谢您宝贵的贡献。确实,产生所需输出的代码是在标签之间没有任何空格的情况下编写文本区域:<textarea></textarea>,正如"Roy"所述。

您的回答可以通过添加更多支持性信息来改进。请【编辑】以添加进一步的细节,例如引用或文档,以便他人可以确认您的回答是否正确。您可以在帮助中心找到关于如何写好答案的更多信息。 - Community

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接