HTML Textarea - 光标从textarea的中心开始而不是顶部

Ben*_*Ben 5 html css textarea cross-browser cursor

我有一个HTML模板和CSS,它呈现一个textarea字段,但是当点击该字段时,光标从文本区域的一半开始,而不是像我期望的那样从左上角开始.

这在IE中不会发生,但在Chrome和FF中也不会发生.我还获得了下面列出的先前值列表,表明正在应用文本框样式.

任何人都可以建议我应该修改哪些CSS属性?

这是HTML:

<input id="description" class="textarea" type="textarea" name="description" cols="70" rows="50">
Run Code Online (Sandbox Code Playgroud)

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

.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;
}
Run Code Online (Sandbox Code Playgroud)

小智 15

在textarea标签之间提供空间通常会导致这种不合需要的空白区域.尝试没有可以解决问题的空间. <textarea></textarea>


Roy*_*Roy 8

我觉得用

<textarea id="description" class="textarea" name="description" cols="70" rows="50"></textarea>
Run Code Online (Sandbox Code Playgroud)

应该解决你的问题.


Far*_*ini 5

你的语法不正确。您可能不包含值为 textarea 的 type 属性,而是按照“roy”建议您必须使用<textarea></textarea>tag