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>
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;
}
you can do it like this:
label { display:inline-block; vertical-align:central; }
textarea { display:inline-block; vertical-align:middle; }
This worked for me.
First the textarea is floated right, then the word "address" appears before it.
It's in reverse order, but displays correctly
<p>
<span style="float:right;"><textarea rows="3" cols="32" name="Add"></textarea></span>
<span style="float:right;">Address</span>
</p>
To show:
Address┌──────────────┐
you forgot : ","
<style>
label, textarea{
vertical-align: middle;
}
</style>
<label>Synopsis: </label> <textarea style="border: 1" rows="3" cols="10"></textarea>
This will always work and you have the flexibility of placing the label at either; top, middle or bottom
HTML:
<div id="mydiv">
<label for="mytextarea">My Label</label>
<textarea name="mytextarea"></textarea>
</div>
CSS:
#mydiv{
display: table-cell;
}
label, textarea{
display: inline-block;
vertical-align: middle; /** Can be switched to 'top' if you so wish **/
}