且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将光标位置设置为输入的左上边缘

更新时间:2023-01-31 20:20:19

这应该有效

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;
}