Bootstrap 5:内联对齐divs而无需更改容器
我一直在努力找到解决方案,似乎找不到任何有效的东西。我正在尝试使用Bootstrap 5为系统制作一些通用组件,并将一个按钮定义为:
<div class="col buttonDiv">
<button type="button" class="btn btn-primary">Foo Bar</button>
</div>
当用户将其放在系统中的容器中时,它会自动生成一个外部容器:
<div class="divContainer">
//button
</div>
因此,如果用户尝试将2个按钮放置,代码看起来像:
<div class="divContainer">
<div class="col buttonDiv">
<button type="button" class="btn btn-primary">Foo Bar</button>
</div>
</div>
<div class="divContainer">
<div class="col buttonDiv">
<button type="button" class="btn btn-primary">Foo Bar</button>
</div>
</div>
如何嵌入这些按钮并能够更改它们的对齐方式?我不可能将类添加到Divcontainers的外部容器中。
我希望有人可以为我阐明这个问题。谢谢。
I've been working on finding a solution to this, and cannot seem to find anything that works. I am trying to make some general components for a system using Bootstrap 5, and have defined a button as:
<div class="col buttonDiv">
<button type="button" class="btn btn-primary">Foo Bar</button>
</div>
When users place this in their container in the system, it automatically generates an outer container:
<div class="divContainer">
//button
</div>
So, if the users try to place 2 buttons, the code will look like:
<div class="divContainer">
<div class="col buttonDiv">
<button type="button" class="btn btn-primary">Foo Bar</button>
</div>
</div>
<div class="divContainer">
<div class="col buttonDiv">
<button type="button" class="btn btn-primary">Foo Bar</button>
</div>
</div>
How do I inline these buttons and also be able to change the alignment on them? It is not possible for me to add classes to the outer container of the divContainers.
I hope someone can shed some light on this problem for me. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
Bootstrap 5
classd-inline
将它们对齐 Docs 在这里use
Bootstrap 5
classd-inline
to align them Docs here