I'm trying to align the label for this text area in the middle of the text box, but it just isn't working. The output looks something like this:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Synopsis: xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Here's the code I've been trying. TY!
<style>
label textarea{
vertical-align: middle;
}
</style>
<label>Synopsis: <textarea style="border: none" rows="7" cols="60">$v_Synopsis</textarea></label>
For vertical alignment, set the parent element's width / height to 100% and add display: table . Then for the child element, change the display to table-cell and add vertical-align: middle .
The <center> tag in HTML is used to set the alignment of text into the center.
Center the text vertically between the top and bottom margins. Select the text that you want to center. in the Page Setup group, and then click the Layout tab. In the Vertical alignment box, click Center.
CODEPEN DEMO
HTML
<div>
<label for="textarea">Textarea:</label>
<textarea cols="40" rows="8" name="textarea" id="textarea"></textarea>
</div>
CSS
label,
textarea{
display:inline-block;
vertical-align:middle;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With