【发布时间】:2018-01-27 19:33:26
【问题描述】:
我用 BS4 制作了一个带有自定义复选标记的复选框。但是元素溢出容器.SamCheckbox。似乎某些元素没有给出完整的高度,因此它破坏了文档流。就像您忘记清除浮动一样 - 但这是通过 flexbox 完成的,而不是浮动。
我怎样才能避免这种情况并让复选框不破坏高度?
<div class="SamCheckbox custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="sam-check-1" value="18">
<i class="custom-control-indicator"></i>
</div>
我给它min-height 以确保高度,但我认为这不是必需的。
.SamCheckbox {
min-height: 34px !important;
&.custom-checkbox {
.custom-control-input {
display: none;
& ~ .custom-control-indicator {
background: none;
border: 1px solid #333;
color: blue;
font-size: 1.6rem;
width: 36px;
height: 36px;
&::before {
position: absolute;
top: 5px;
left: 5px;
}
}
&:checked ~ .custom-control-indicator {
border: 1px solid #999;
background: none;
}
&:disabled ~ .custom-control-indicator {
border: none;
background: none;
}
}
}
}
如何确保<div class="SamCheckbox"> 包含所有子元素并具有完整高度?
这是一个在上下文中使用的代码笔:
【问题讨论】:
-
不清楚你在问什么..?有什么问题...
-
我编辑了我的问题(用粗体突出显示)更清楚
-
据我所知,它确实包含“所有子元素并具有完整高度”。一点也不知道你到底想用那个复选框做什么......
-
我的回答有用吗,解决了你的问题?
-
是的。我接受了。
标签: html css flexbox bootstrap-4