Html 垂直对齐复选框标签?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15230820/
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 06:09:50  来源:igfitidea点击:

Vertical align checkbox label?

htmlcss

提问by user2043533

I have checkboxes like this:

我有这样的复选框:

<label class="checkbox-label"><input type="checkbox" value="115">Administrators</label>

But I cannot fugure out how to style the label to be center valigned to the checkbox.

但我无法弄清楚如何将标签的样式设置为与复选框居中对齐。

I tried adding vertical-align:middle;

我尝试添加 vertical-align:middle;

Thanks

谢谢

回答by Artur K?pp

This is what I did with your code.

这就是我对你的代码所做的。

html

html

<label class="checkbox-label"><input type="checkbox" value="115">-middle</label>

css

css

label.checkbox-label input[type=checkbox]{
    position: relative;
    vertical-align: middle;
    bottom: 1px;
}

Fiddle

小提琴

回答by James Coyle

Try using:

尝试使用:

vertical-align: text-bottom;

jsFiddle

js小提琴

Edit:

编辑:

 <input id="checkbox" type="checkbox" value="115">
 <label class="checkbox-label" for="checkbox">Administrators</label>

jsFiddle

js小提琴

回答by Honorable Chow

Adjust the line height of the label.

调整标签的行高。