Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Placeholder text is not vertically centered in Safari

Do you have any idea on how to get the placeholder attribute to vertically center in safari? Though when you start typing, the text is perfectly centred.

like image 244
Donny Avatar asked Feb 17 '12 05:02

Donny


People also ask

How do you vertically align a placeholder text?

To center it vertically, I multiplied the height of the element to 7.5% and make it line-height. Show activity on this post. Show activity on this post. Use the line-height property to make the placeholder vertically centered.

How do you style a placeholder text?

Use the ::placeholder pseudo-element to style your placeholder text in an <input> or <textarea> form element. Most modern browsers support this, but for older browsers, vendor prefixes will be required.


1 Answers

-Safari Solution-

I got stuck on this issue for a long time despite using

input::-webkit-input-placeholder { line-height:normal!important; }

It turns out that having a line-height in the immediate input element was breaking my input::webkit-input-placeholder line-height.

Solution extended:

I removed the line-height in my input style and it fixed my issue.

like image 138
Ariella Avatar answered Sep 28 '22 00:09

Ariella