gpt4 book ai didi

html - 并排生成按钮不适用于显示器 :inline-block

转载 作者:太空宇宙 更新时间:2023-11-03 19:26:18 24 4
gpt4 key购买 nike

我正在使用 Angular 生成按钮,这些按钮一个放在另一个之上,而不是并排放置

<div *ngIf="response">
<div *ngFor="let hit of response.hits.hits">
<button class="btn btn-primary" role="button" style="display:inline-block">{{hit._source.keywords[0].keyword}}</button>
</div>
</div>

我已经尝试过 style="display:inline-block" 以及 style="display:inline" 并且它们都以一个高于另一个结束。它与 *ngFor 的工作方式有关,还是我可以使用其他一些 CSS 样式?

最佳答案

它们是垂直堆叠的,因为你生成了一系列 div,它们是 block 元素。

您应该将 ngFor 循环应用于按钮:

<div *ngIf="response">
<button *ngFor="let hit of response.hits.hits" ... style="display: inline-block">...</button>
</div>

或者将display样式应用于内部div:

<div *ngIf="response">
<div *ngFor="let hit of response.hits.hits" style="display: inline-block">
<button...>...</button>
</div>
</div>

关于html - 并排生成按钮不适用于显示器 :inline-block,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52876541/

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