gpt4 book ai didi

html - 即使通过 Bootstrap 设置宽度后,控件也无法正确对齐

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

我正在创建一个每行包含四个控件的用户界面。它会有一个标签和控件,后面跟着另一个标签和控件。如果您在我的标记中看到,我已经为标签设置了 col-md-2,为控件设置了 col-md-4,但是第二个控件似乎换行并转到下一行。我不确定为什么要这样做,因为它的总宽度为 12。如果您单击右上角的“编辑”按钮,您可以切换以查看控件

我还创建了一个 stackblitz 来重现这个问题

https://angular-lmck2c.stackblitz.io

标记

<style>
label {
margin-left: 0.5rem;
vertical-align: middle
}


.panel-heading {
color: black;
/* background-color: #F5F7F7; */
border-color: #ddd;
overflow: hidden;
padding-top: 5px !important;
padding-bottom: 5px !important;
}

.panel-heading .left-label {
display: inline-block;
padding-top: 5px !important;

}
.panel-heading label {
margin-bottom: 0px !important;
}
</style>



<div class="card" style="height: 100%; width: 100%;">
<div class="card-header panel-heading">
<span class="left-label" style="font-size: 18px; font-weight: bold; ">Fund Terms</span>
<div class="pull-right" style="padding-right:10px; display: inline-block; vertical-align:middle">
<label style="text-align: center; vertical-align:middle" class="btn btn-primary"
[ngClass]="{'btn-primary': EditMode, 'btn-default': !EditMode }"><input type="checkbox"
[(ngModel)]="EditMode" class="hidden" />Edit Mode</label>

</div>
</div>

<div class="card-body">


<div class="form-group row" style="width: 100%;">

<label for="inputName" class="col-md-2 col-form-label modal-label">Name</label>
<div class="col-md-4">
<div *ngIf="!EditMode">Test Name</div>
<input *ngIf="EditMode" kendoTextBox [readonly]="false" class="form-control form-control-sm"
/>
</div>

<label for="inputOffice" class="col-md-2 col-form-label ">Side Letter Agreement</label>
<div class="col-md-4">
<div *ngIf="!EditMode">Test</div>
<label *ngIf="EditMode" style="font-size: 13px;font-weight: normal;cursor: pointer">
<input type="checkbox" style="width: 13px; height: 13px;" />
Yes </label>

</div>

</div>

<div class="form-group row">
<label for="inputTitle" class="col-md-2 col-form-label ">Vehicle Type</label>
<div class="col-md-4">
<div *ngIf="!EditMode">Test Vehicle Type</div>
<kendo-dropdownlist *ngIf="EditMode" style="width:100%" class="form-control form-control-sm"
[filterable]="false" textField="NAME" [valuePrimitive]="true" valueField="ID">
</kendo-dropdownlist>
</div>


<label for="inputEmail" class="col-md-2 col-form-label ">Side Letter Details</label>
<div class="col-md-4">
<div *ngIf="!EditMode">Test</div>
<textarea *ngIf="EditMode" kendoTextArea></textarea>
</div>
<div class="col-md-4">

</div>
</div>


<div class="form-group row">

<label for="inputEmail" class="col-md-2 col-form-label ">Investment Manager (Firm)</label>
<div class="col-md-4">
<div *ngIf="!EditMode">Test</div>
<input *ngIf="EditMode" kendoTextBox [readonly]="false" class="form-control form-control-sm" />
</div>

<label for="inputTitle" class="col-md-2 col-form-label ">Plan Asset Fund</label>
<div class="col-md-4">
<div *ngIf="!EditMode">Test Asset Fund</div>
<label style="font-size: 13px;font-weight: normal;cursor: pointer">
<input type="checkbox" style="width: 13px; height: 13px;" />
Yes </label>
</div>

</div>

<div class="form-group row">

<label for="inputEmail" class="col-md-2 col-form-label ">Investment Manager (Firm)</label>
<div class="col-md-4">
<div *ngIf="!EditMode">Test</div>
<input *ngIf="EditMode" kendoTextBox [readonly]="false" class="form-control form-control-sm" />
</div>



</div>


<div class="form-group row">

<label for="inputEmail" class="col-md-2 col-form-label ">NAV Reporting Cycle</label>
<div class="col-md-4">
<div *ngIf="!EditMode">Test</div>
<kendo-dropdownlist *ngIf="EditMode" style="width:100%" class="form-control form-control-sm"
[filterable]="false" textField="NAME" [valuePrimitive]="true" valueField="ID">
</kendo-dropdownlist>
</div>



</div>


<div class="form-group row">

<label for="inputName" class="col-md-2 col-form-label ">Fund Currency</label>
<div class="col-sm-4">
<div>Test</div>
</div>



</div>

<div class="form-group row">

<label for="inputName" class="col-md-2 col-form-label ">Audit Year End</label>
<div class="col-sm-4">
<div>Test</div>
</div>



</div>





<div class="btn-toolbar" style="padding-top:40px;">

<span *ngIf="EditMode"><button type="button" class="btn btn-primary btn-view-all btn mr-3"
(click)="saveManager()">Save</button>

</span>


</div>
</div>
</div>

最佳答案

我认为答案是因为您的标签留有边距。如果你把它去掉,所有元素都应该放在一行中。

通常,当元素不适合 Bootstrap 行时,我的第一个检查始终是查看是否有额外的边距或填充在不应该的地方。

如果您确实需要标签前的额外间距,请尝试将它们包裹在包含的 div 中,然后在该包裹上添加 .col-* 类。然后您可以尝试向标签添加额外的间距。

<div class="col-md-4">
<label></label>
</div>

关于html - 即使通过 Bootstrap 设置宽度后,控件也无法正确对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56398291/

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