html - 如何让标签停留在选择元素的顶部?

标签 html css label html-select

用这个 html:

<h2>Where (Location / Station)</h2>
<label for="selwhere">Select the locations for the job type selected above</label>
<select name="selwhere" id="selwhere" multiple="multiple">
  <option value="linecook">Line cook</option>
  <option value="barrista">Barrista</option>
  <option value="securityguard">Security Guard</option>
  <option value="fignipper">Nipper of Figs</option>
</select>

我的标签落到选择元素的底部:

enter image description here

我希望它位于顶部。我需要什么 html 或 CSS?

最佳答案

只需使用 vertical-align:top :

label {
  vertical-align: top;
}
<label for="selwhere">Select the locations for the job type selected above</label>
<select name="selwhere" id="selwhere" multiple="multiple">
  <option value="linecook">Line cook</option>
  <option value="barrista">Barrista</option>
  <option value="securityguard">Security Guard</option>
  <option value="fignipper">Nipper of Figs</option>
</select>

关于html - 如何让标签停留在选择元素的顶部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32040259/

相关文章:

html - 谷歌地图信息窗口显示在左上角

php - 如何使用准备好的语句在 PHP 中输​​出 MySQL 表

Javascript 函数在页面加载时触发,而不是在点击时触发

javascript - 在精确的区域 Javascript 中拖动任何一个跨度

matlab - 如何在 X 轴上始终显示 "labels"

javascript - Chrome 扩展程序中的功能无法运行

html - CSS 左右浮动

javascript - IE : first-of-type 的 CSS 行为

python - Matplotlib 轴标签部分的斜体 - 应用于默认字体但不指定字体

printing - Zebra 标签 zpl 未在物理打印中完全显示,但在虚拟打印中显示