【问题标题】:HTML Textarea - cursor starting in center of textarea rather than topHTML Textarea - 光标从文本区域的中心而不是顶部开始
【发布时间】:2011-08-13 12:37:55
【问题描述】:

我有一个呈现 textarea 字段的 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;
}

【问题讨论】:

  • 输入元素没有类型“textarea”,而是一个textarea元素。

标签: html css cross-browser textarea text-cursor


【解决方案1】:

在 textarea 标记之间提供空格通常会导致出现这种不受欢迎的空格。试试没有空格的代码就可以了。 &lt;textarea&gt;&lt;/textarea&gt;

【讨论】:

    【解决方案2】:

    我认为使用

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

    应该可以解决你的问题。

    【讨论】:

      【解决方案3】:

      您的语法不正确。您可能不包含值为 textarea 的类型属性,而是作为“roy”建议您必须使用 &lt;textarea&gt;&lt;/textarea&gt; 标签

      【讨论】:

        猜你喜欢
        • 2021-02-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-04-09
        • 2019-06-14
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多