Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Input placeholder vertical align

Tags:

How to properly vertically center placeholder in an input field?

input[type='text']{
  background-color: rgba(255,255,255,.4);
  border:3px solid rgba(0,0,0,.5);
  min-height: 45px;
  border-radius: 6px;
  color:#fff;
}
input[type='text']::-webkit-input-placeholder {
  font-size: 30px;
  color: rgba(255, 255, 255, 0.4);
  line-height: 30px;
  text-transform: uppercase;
  vertical-align: middle;
}

Here is the code https://jsfiddle.net/u6qfwg3w/

like image 250
Razvan Cuceu Avatar asked Aug 09 '16 15:08

Razvan Cuceu


People also ask

How do you align a placeholder vertically?

Either drag the image and wait for a horizontal (red) guide appearing in de middle of your image, then release the mouse button. Or select both the placeholder and the image (shift+click) and under picture tools, format tab, click the align button and choose align middle option.

How do you set placeholder alignment?

In most of the browsers, placeholder texts are usually aligned in left. The selector uses text-align property to set the text alignment in the placeholder. This selector can change browser to browser.

How do you center a placeholder text vertically in textarea?

Use the line-height property to make the placeholder vertically centered.


1 Answers

You forgot to add this css to input element:

input[type='text']{
 font-size: 30px;
 color: rgba(255, 255, 255, 0.4);
 line-height: 30px;
}

Here is the fiddle: fiddle link

like image 193
Teuta Koraqi Avatar answered Oct 12 '22 23:10

Teuta Koraqi