Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to add some padding-top on a placeholder of a text area

I know about how to stylize the placeholder from here css tricks

But I need to know about how to apply to a specific text area.My text-area has class "message".

Thanks.

Actually I used padding.But was interested about thee styling of placeholder with a css3 seelctor.

any help?

like image 976
Abhisek Malakar Avatar asked Nov 26 '14 10:11

Abhisek Malakar


People also ask

How do you add padding to a placeholder input?

Just add padding to the input like this: . tbsearchbar { padding-top: 10px; color: red; //To add some color. }

How do you place a placeholder in text area?

The placeholder attribute of the <textarea> element is used to set a placeholder text in the textarea. A placeholder is considered as a hint, like “Enter you name”, “Enter mobile number”, “Write in 100 words”, etc. Above, text is the hint you want to set for the textarea as a placeholder text.

How do you style placeholder text?

The ::placeholder selector selects form elements with placeholder text, and let you style the placeholder text. The placeholder text is set with the placeholder attribute, which specifies a hint that describes the expected value of an input field.


2 Answers

All you need is .message { padding-top: 10px; } to achieve the result you're after.

It will apply to any <textarea> that has the class of message

EDIT

If you don't want to apply padding to the element, try this instead. It literally just targets the placeholder.

.message::-webkit-input-placeholder {
   padding-top: 10px;
}

.message::-moz-input-placeholder {
   padding-top: 10px;
}

.message:-moz-input-placeholder {
   padding-top: 10px;
}

.message:-ms-input-placeholder {
   padding-top: 10px;
}

Can be seen in action here, I set up 2 <textarea>'s to show this - http://jsfiddle.net/andyjh07/tan7k4rf/

like image 68
Andy Holmes Avatar answered Oct 04 '22 12:10

Andy Holmes


This what you are looking for?

<textarea  placeholder="Placeholder text!" class="message"></textarea>
<textarea  placeholder="Placeholder text!" ></textarea>

.message::-webkit-input-placeholder {padding-top: 10px;}
.message:-moz-placeholder { /* Firefox 18- */padding-top: 10px;}
.message::-moz-placeholder {  /* Firefox 19+ */padding-top: 10px;}
.message:-ms-input-placeholder {padding-top: 10px;}

http://jsfiddle.net/92gnt7qt/3/

like image 38
Gezzasa Avatar answered Oct 04 '22 12:10

Gezzasa