为文本区域制作一个标签,放在它旁边,但垂直居中对齐
请看一下这个小提琴: http://jsfiddle.net/hughbe/QYGcq/
如您所见,标签对于 应该是在
textarea
旁边,但是,我想使标签垂直位于文本区域旁边,或位于文本区域的顶部,而不是像小提琴中那样位于底部。
我尝试将其 css 设置为 vertical-align: middle
但这不起作用。我必须做什么才能使标签在顶部或中间对齐?
谢谢。
Please take a look at this fiddle: http://jsfiddle.net/hughbe/QYGcq/
As you can see, the label for the <textarea id = "FooText"></textarea>
is next to the textarea
as it should be, however, I would like to make the label vertically next to the textarea, or at the top of the textarea, instead of at the bottom, like it is in that fiddle.
I have tried setting it's css to vertical-align: middle
but that didn't work. What must I do to make the label aligned at the top or the middle?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在文本区域上使用
vertical-align: middle
http://jsfiddle.net/VxY6m/因为垂直对齐意味着相对于文本行 - 在本例中为标签。
Use
vertical-align: middle
on the textarea http://jsfiddle.net/VxY6m/Because vertical align meant to be relative to text line - label in this case.
试试这个:
我所做的是将标签设为块元素并对其应用顶部填充。
另请参阅fiddle。
Try this:
What I did was make the label a block element and apply a top padding to it.
See the fiddle also.