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

标签 html css cross-browser textarea text-cursor

我有一个呈现文本区域字段的 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></textarea>

关于HTML Textarea - 光标从 textarea 的中心而不是顶部开始,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7050460/

相关文章:

css - 为什么底部填充和底部边距无助于增加这些链接之间的垂直间距?

html - 如何在父div中水平居中div

javascript - 垂直居中,绝对定位的子力父高度匹配

css - 我的自定义光标代码: How do I get it to work in IE?的演变

jquery - IE 中的样式(jquery)复选框按钮自动换行

javascript - 在表单提交之前调用函数的更好方法是什么?

jquery .stop() 在每次悬停时降低 div 的高度

javascript - 有没有测量过 CSS 在编码效果方面比 Javascript 快多少?

javascript - 在鼠标悬停时用背景图像替换文本颜色

javascript - IE10 开发工具如何报告兼容性 View ?