如何将光标位置设置为输入的左上边缘 [英] How to set cursor position to the top-left edge of input

查看:423
本文介绍了如何将光标位置设置为输入的左上边缘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我输入如下内容:

如何将光标位置设置到此输入字段的左上边缘?

How can I set cursor postition to the top-left edge of this input field?

推荐答案

这应该有效

input {
   padding-top: 0;
   padding-left: 0;
   line-height: 1em; // this probably doesn't matter
}

例如 40px 0 之类的东西。因此顶部和底部的顶部和底部有很大的空间( padding )。

It seems that you likely have padding of like 40px 0 or something. So the top and bottom has a lot of space (padding) on the top and bottom.

编辑:

如果这不起作用,则您的身高可能 设置为您的输入,这很糟糕。由于输入只能是一行。如果要多行,请使用< textarea>< / textarea> 标记代替< input>

If that didn't work, you likely have a height set for your input, which is bad. Since an input is intended to only be one line. If you want multiple lines you are to use <textarea></textarea> tags instead of <input>

如果您不想使用< textarea> ,但是由于某种原因而具有更高的高度, 删除您输入的高度,然后像这样使用填充

If you don't want to use <textarea> but have a bigger height for some reason, remove the height from your input and just use padding like this

http://jsfiddle.net/PVRp4/

input {
    padding: 0 0 400px 0;
}

这篇关于如何将光标位置设置为输入的左上边缘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆