Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to vertically align text in input type="text"? [duplicate]

Tags:

html

css

There is <input type="text" /> I need to set vertical alignment of the entered text. For example middle or top. http://jsfiddle.net/eSPMr/

like image 519
Oleg Dats Avatar asked Sep 10 '12 16:09

Oleg Dats


2 Answers

Use padding to fake it since vertical-align doesn't work on text inputs.

jsFiddle example

CSS

.date-input {          width: 145px;     padding-top: 80px; }​ 
like image 105
j08691 Avatar answered Oct 03 '22 23:10

j08691


An alternative is to use line-height: http://jsfiddle.net/DjT37/

.bigbox{     height:40px;     line-height:40px;     padding:0 5px; } 

This tends to be more consistent when you want a specific height as you don't need to calculate padding based on font-size and desired height, etc.

like image 29
Shmiddty Avatar answered Oct 04 '22 00:10

Shmiddty