Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to adjust the alignment of placeholder text in input box?

enter image description here

The placeholder text in the third box appears in the middle while i want to be at the top. HTML

<div id="message">
    <ul>
      <li><h1>Send us a message</h1></li>
      <li><input type="text" placeholder="Name"></li>
      <li><input type="text" placeholder="Email"></li>
      <li><input type="text" style="height:150px;" placeholder="Message"></li>
      <li><a href="#">Send</a></li>
    </ul>
</div>

Here is JSFiddle

like image 638
Orahmax Avatar asked Jan 09 '14 14:01

Orahmax


2 Answers

If you're wanting a multi-line input field you should use the textarea element.

<li>
    <textarea placeholder="Message"></textarea>
</li>

You can then style this however you like using the textarea selector:

#message input,
#message textarea {
    width: 250px;
    height: 40px;
    padding: 10px;
}

#message li input[type=text],
#message li textarea {
    border-radius: 5px;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border: none;
}

#message li textarea {
    height: 150px;
    resize: none;
}

JSFiddle demo.

like image 164
James Donnelly Avatar answered Sep 19 '22 21:09

James Donnelly


Try this out

::-webkit-input-placeholder {
   text-align:center;
}

:-moz-placeholder { /* Firefox 18- */
   text-align:center;  
}

::-moz-placeholder {  /* Firefox 19+ */
   text-align:center;  
}

:-ms-input-placeholder {  
   text-align:center; 
}
like image 36
Shabeer Mothi Avatar answered Sep 23 '22 21:09

Shabeer Mothi