如何在多行上拆分BootStrap徽章?

时间:2017-09-25 10:45:23

标签: twitter-bootstrap bootstrap-4

参考:BootStrap badge

默认情况下,会根据逗号分割项目。然而,在按下输入时,我需要将每个项目放在新行上。

1 个答案:

答案 0 :(得分:3)

Bootstrap badgesspan元素,这意味着它们默认显示为inline。如果要在新行上显示顺序标记,则可以将它们包装在块元素中,例如div

<div>
    <span class="badge badge-secondary">Badge 1</span>
</div>
<div>
    <span class="badge badge-secondary">Badge 2</span>
</div>

或应用自己的风格:

HTML:

<span class="badge badge-secondary block-badge">Badge 1</span>
<span class="badge badge-secondary block-badge">Badge 1</span>

CSS:

.badge.block-badge {
    display: block;
}