Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep text aligned with the middle of a textarea?

Tags:

html

css

<html>
<body>

This should be level with the middle of the box!
<textarea id="id" name="name" rows="9" cols="50">Text is in here!</textarea>

</body>
</html>

Picture of what this ends up looking like.

How do I make it so that the text to the left of the box stays level with the middle of the box, even if it's being dragged around? Can it be done with CSS, or will it require Javascript?

like image 753
ebol4 Avatar asked Dec 12 '25 17:12

ebol4


1 Answers

The easiest way (if you want to avoid tables) is to float your label and set its line-height equal to textarea height:

See http://jsfiddle.net/pctVh/2

like image 59
Michal Klouda Avatar answered Dec 14 '25 10:12

Michal Klouda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!