Html 如何将文本区域的标签与顶部对齐?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11010491/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How will I align the label of a text area to top?
提问by Arjel
I do have a table data as shown below:
我确实有一个表数据,如下所示:
<td>
<label for="title">Title : </label>
<textarea rows="5" id="title" name="title"></textarea>
</td>
the default location for the label is at the bottom. How will I place the label aligned with the top of the text area?
标签的默认位置在底部。如何将标签与文本区域的顶部对齐?
回答by kapa
With the following CSS:
使用以下 CSS:
?textarea { vertical-align: top; }?
- jsFiddle Demo
vertical-align
on MDN:The vertical-align CSS property specifies the vertical alignment of an inline or table-cell element.
- What is Vertical Align? on CSS-Tricks
- jsFiddle 演示
vertical-align
在 MDN 上:Vertical-align CSS 属性指定内联或表格单元格元素的垂直对齐方式。
- 什么是垂直对齐?关于 CSS 技巧
回答by SVS
@Bazmegakapa Great answer! We can also do it this way
@Bazmegakapa 很好的答案!我们也可以这样做
label{display:block; float:left;}?
fiddle demo: http://jsfiddle.net/kaMqg/1/
小提琴演示:http: //jsfiddle.net/kaMqg/1/
回答by Kiur Jullis
Use br tag.
使用 br 标签。
<td>
<label for="title">Title : </label>
<br>
<textarea rows="5" id="title" name="title"></textarea>
</td>