如何将这两个元素布局使用CSS在同一行上?
我在Angular HTML页面中有以下代码,我需要使标签位于下拉列表
<div *ngIf="this.userRole == 'myrequests' " class="col-2" [ngClass]="{ 'd-none': view != 'list' }" id="statusFilter">
<label class="font-weight-bold text-secondary" for="statusFilter">Filter By Status:</label>
<select style="display: inline-block ;"
name="statusFilter"
[(ngModel)]="statusFilter"
class="form-control"
(change)="setStatusFilter()">
<option [value]="'none'" disabled selected><strong> Choose Filter: </strong></option>
<option *ngFor="let status of statuses" [value]="status.name">
{{ status.name }}
</option>
</select>
</div>
typescript文件旁边的标签具有数组:
statuses = [
{ id: 0, name: "All" },
{ id: 1, name: "Approved" },
{ id: 2, name: "Created" },
{ id: 3, name: "Rejected" },
{ id: 4, name: "Cancelled" },
{ id: 5, name: "Approval Pending" },
];
所需的布局我想在同一行上,
I have the following code in Angular html page which i need to make the label sit next to the dropdown list
<div *ngIf="this.userRole == 'myrequests' " class="col-2" [ngClass]="{ 'd-none': view != 'list' }" id="statusFilter">
<label class="font-weight-bold text-secondary" for="statusFilter">Filter By Status:</label>
<select style="display: inline-block ;"
name="statusFilter"
[(ngModel)]="statusFilter"
class="form-control"
(change)="setStatusFilter()">
<option [value]="'none'" disabled selected><strong> Choose Filter: </strong></option>
<option *ngFor="let status of statuses" [value]="status.name">
{{ status.name }}
</option>
</select>
</div>
typescript file has the array:
statuses = [
{ id: 0, name: "All" },
{ id: 1, name: "Approved" },
{ id: 2, name: "Created" },
{ id: 3, name: "Rejected" },
{ id: 4, name: "Cancelled" },
{ id: 5, name: "Approval Pending" },
];
The desired layout I want to be on the same line
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(2)
对于父母,请使用FlexBox:
For the parent class, use flexbox:
您可以给标签一个显示:内联块;同样。
或者,您可以将标签和两者都放在不同的div中,并给那些Div的一定宽度。
You could give the label a display: inline-block; aswell.
Or you could put the label and both in a different div and give those div's a certain width.