[英]How to vertically align a checkbox with its label in MaterializeCSS
有沒有辦法在MaterializeCSS中垂直對齊(居中)復選框及其標簽? 這個小提琴演示了這個問題 -我希望復選框相對於藍色框垂直居中。 如果您從小提琴中刪除實物並使用香草HTML / CSS,它將起作用。
謝謝!!
實體化版本: 0.100.2
HTML:
<form>
<div>
<input id="myinput" type="checkbox" />
<label for="myinput">
<div class="label-content">
Label Text
</div></label>
</div></form>
CSS:
label {
display:inline-block;
vertical-align:middle;
}
.label-content {
height:100px;
background-color:aliceblue;
border: 1px solid blue;
}
您必須將top:50%
和一些負邊距( 元素高度的一半 )設置為label的:before
和:after
偽類。
.parent [type="checkbox"]+label:before,
.parent [type="checkbox"]:not(.filled-in)+label:after {
top: 50%;
margin-top: -9px;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.