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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 01:00:12  来源:igfitidea点击:

How will I align the label of a text area to top?

htmlcssformslayout

提问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; }?

回答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>