Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set cursor position to the top-left edge of input

Tags:

html

css

Let I've an input field like the following:

enter image description here

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

like image 454
St.Antario Avatar asked Mar 04 '14 08:03

St.Antario


People also ask

How do I change the cursor position in TinyMCE editor?

Setting the cursor position You can also hold down shift and then move the cursor with the arrow keys on the keyboard to select content. It has the same effect. The TinyMCE bookmarks this location with the Bookmark Manager API, and then loads the selected location later.

How do you move the input field to the right?

Add the text-align property set to “right” for the input.


3 Answers

This should work

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

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.

EDIT:

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>

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;
}
like image 66
CRABOLO Avatar answered Sep 22 '22 07:09

CRABOLO


Textarea or big size text input ? Input is for single line element use <textarea></textarea>. Code pls ... Remove all whitespace between <textarea></textarea> or <input></input>tags.

Or in your css code you have text-align: center to your parent elements, or somewhere else but its still formating your input. Press f12 in the browser and check the element.

like image 41
user1597594 Avatar answered Sep 20 '22 07:09

user1597594


AFAIR there is no option the place the cursor inside of an input field, except left, center, or right. Vertical Alignment isn't possible.

like image 43
telegnom Avatar answered Sep 21 '22 07:09

telegnom