html - 对齐文本区域字段旁边的标签,居中?纯CSS解决方案

标签 html css

所以我得到了这个片段: (这是 jsfiddle )

<div><label style="height: 58px;">Label</label>
    <textarea>11111</textarea>
</div>

<br/>
<br/>
<br/>
<br/>

<div><label style="height: 158px;">Label</label>
    <textarea style="height:199px">11111</textarea>
</div>

这是CSS

label{
    display:inline-block;
    background-color: grey;
}

这是可悲的结果:

enter image description here

我希望标签位于文本区域字段的中心。有人知道这里发生了什么吗?

最佳答案

您必须为文本区域设置 vertical-align: middle 属性(或为您想要为其指定标签的任何元素 - 例如,也适用于多选)。

Working fiddle here

关于html - 对齐文本区域字段旁边的标签,居中?纯CSS解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22459538/

相关文章:

css - .fields_with_errors 的 Bootstrap 样式不起作用

css - 调整大小时随背景一起移动的元素

javascript - 透明 DIV 覆盖

javascript - 如何使用 jQuery 在移动网络浏览器上制作滚动动画?

javascript - 从 CSS 脚本打开 Jquery 以来的文件夹

php - 如何在已解析的 HTML 数据中查找元素

css - 设置div和浏览器边框之间的距离?

html - 页眉左侧不需要的空间

javascript - 使用javascript返回标签的 "top"属性

css - 具有特定长度的第一种颜色的水平清晰背景渐变