gpt4 book ai didi

css - 是什么导致
比它的 child 高?

转载 作者:行者123 更新时间:2023-11-28 10:31:37 25 4
gpt4 key购买 nike

是什么导致 div .btn-group 比它的所有子元素都高?

参见 JSFiddle用于应用 CSS 和视觉演示。

<div class="top-box p-sm">
<div role="toolbar" class="btn-toolbar">
<div class="btn-group red">
<button type="button" class="btn btn-default">Save</button>
<div class="tooltip-button-helper" aria-describedby="ttRename">
<button type="button" class="btn btn-default"
style="pointer-events: none;">Rename</button>
</div>
</div>
</div>
</div>

.btn-group {
background-color: red;
}

.tooltip-button-helper {
display: inline-block;
cursor: not-allowed;
}

// fix styling of buttons in ButtonGroups and ButtonToolbars which got broken by inserting another div
.btn-toolbar>.tooltip-button-helper>.btn {
margin-left: 5px;
}

.btn-group>.tooltip-button-helper:first-child:not(:last-child)>.btn:not(.dropdown-toggle) {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}

.btn-group>.tooltip-button-helper:last-child:not(:first-child)>.btn,
.btn-group>.tooltip-button-helper:not(:first-child)>.dropdown-toggle {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}

.btn-group .btn+.tooltip-button-helper>.btn,
.btn-group .tooltip-button-helper>.btn+.btn-group,
.btn-group .tooltip-button-helper>.btn-group+.btn,
.btn-group .tooltip-button-helper>.btn-group+.btn-group {
margin-left: -1px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="top-box p-sm">
<div role="toolbar" class="btn-toolbar">
<div class="btn-group">
<button type="button" class="btn btn-default">Save</button>
<div class="tooltip-button-helper" aria-describedby="ttRename">
<button type="button" class="btn btn-default" style="pointer-events: none;">Rename</button>
</div>
</div>
</div>
</div>
What causes the div .btn-group (with the dark red background) to be taller than its child elements?

最佳答案

它是 inline-block 元素的垂直对齐。如果您将它们设置为 vertical-align: top,它将摆脱底部的空间。 https://jsfiddle.net/jdn58g40/3/

.btn-group {
background-color: red;
}

.tooltip-button-helper {
display: inline-block;
cursor: not-allowed;
}

// fix styling of buttons in ButtonGroups and ButtonToolbars which got broken by inserting another div
.btn-toolbar>.tooltip-button-helper>.btn {
margin-left: 5px;
}

.btn-group>.tooltip-button-helper:first-child:not(:last-child)>.btn:not(.dropdown-toggle) {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}

.btn-group>.tooltip-button-helper:last-child:not(:first-child)>.btn,
.btn-group>.tooltip-button-helper:not(:first-child)>.dropdown-toggle {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}

.btn-group .btn+.tooltip-button-helper>.btn,
.btn-group .tooltip-button-helper>.btn+.btn-group,
.btn-group .tooltip-button-helper>.btn-group+.btn,
.btn-group .tooltip-button-helper>.btn-group+.btn-group {
margin-left: -1px;
}

button, .tooltip-button-helper {
vertical-align: top !important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="top-box p-sm">
<div role="toolbar" class="btn-toolbar">
<div class="btn-group">
<button type="button" class="btn btn-default">Save</button>
<div class="tooltip-button-helper" aria-describedby="ttRename">
<button type="button" class="btn btn-default" style="pointer-events: none;">Rename</button>
</div>
</div>
</div>
</div>
What causes the div .btn-group (with the dark red background) to be taller than its child elements?

关于css - 是什么导致 <div> 比它的 child 高?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42964917/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com