admin管理员组文章数量:1333180
Could someone help me align the text and checkbox so they are both inside the Tabs here please, preferably without CSS or using inline CSS.
Ive tried a few diffent approaches, but bootstrap isn't my strong suit, im using a CRUD framework that handles the bootstrap side of things, but I need to do somthing like this so the end user can select tabs to export.
<div class="container">
<ul class="nav nav-tabs">
<!-- Tab 1 with Checkbox -->
<li class="nav-item">
<a class="nav-link" href="#">
<span class="d-flex align-items-center">
Badger
<input class="form-check-input" type="checkbox" id="checkTab1">
</span>
</a>
</li>
<!-- Tab 2 with Checkbox -->
<li class="nav-item">
<a class="nav-link" href="#">
<span class="d-flex align-items-center">
Cat
<input class="form-check-input" type="checkbox" id="checkTab2">
</span>
</a>
</li>
<!-- Tab 2 with Checkbox -->
<li class="nav-item">
<a class="nav-link" href="#">
<span class="d-flex align-items-center">
Foo
<input class="form-check-input" type="checkbox" id="checkTab3">
</span>
</a>
</li>
<!-- Tab 2 with Checkbox -->
<li class="nav-item">
<a class="nav-link" href="#">
<span class="d-flex align-items-center">
Bar
<input class="form-check-input" type="checkbox" id="checkTab4">
</span>
</a>
</li>
</ul>
</div>
Fiddle here
Could someone help me align the text and checkbox so they are both inside the Tabs here please, preferably without CSS or using inline CSS.
Ive tried a few diffent approaches, but bootstrap isn't my strong suit, im using a CRUD framework that handles the bootstrap side of things, but I need to do somthing like this so the end user can select tabs to export.
<div class="container">
<ul class="nav nav-tabs">
<!-- Tab 1 with Checkbox -->
<li class="nav-item">
<a class="nav-link" href="#">
<span class="d-flex align-items-center">
Badger
<input class="form-check-input" type="checkbox" id="checkTab1">
</span>
</a>
</li>
<!-- Tab 2 with Checkbox -->
<li class="nav-item">
<a class="nav-link" href="#">
<span class="d-flex align-items-center">
Cat
<input class="form-check-input" type="checkbox" id="checkTab2">
</span>
</a>
</li>
<!-- Tab 2 with Checkbox -->
<li class="nav-item">
<a class="nav-link" href="#">
<span class="d-flex align-items-center">
Foo
<input class="form-check-input" type="checkbox" id="checkTab3">
</span>
</a>
</li>
<!-- Tab 2 with Checkbox -->
<li class="nav-item">
<a class="nav-link" href="#">
<span class="d-flex align-items-center">
Bar
<input class="form-check-input" type="checkbox" id="checkTab4">
</span>
</a>
</li>
</ul>
</div>
Fiddle here
Share Improve this question edited Nov 20, 2024 at 16:39 isherwood 61.1k16 gold badges121 silver badges169 bronze badges asked Nov 20, 2024 at 15:36 MonkeyHunterMonkeyHunter 11 Answer
Reset to default 0in your case can use d-flex and align-items-center classes or use custom css, bootstrap tab borders and padding interfere with the checkbox placement
<div class="container">
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link d-flex align-items-center" href="#">
<span>Badger</span>
<input class="form-check-input ms-auto" type="checkbox" id="checkTab1">
</a>
</li>
<li class="nav-item">
<a class="nav-link d-flex align-items-center" href="#">
<span>Cat</span>
<input class="form-check-input ms-auto" type="checkbox" id="checkTab2">
</a>
</li>
<li class="nav-item">
<a class="nav-link d-flex align-items-center" href="#">
<span>Foo</span>
<input class="form-check-input ms-auto" type="checkbox" id="checkTab3">
</a>
</li>
<li class="nav-item">
<a class="nav-link d-flex align-items-center" href="#">
<span>Bar</span>
<input class="form-check-input ms-auto" type="checkbox" id="checkTab4">
</a>
</li>
本文标签: How can I place a checkbox next to Bootstrap tab text and align all in the tabStack Overflow
版权声明:本文标题:How can I place a checkbox next to Bootstrap tab text and align all in the tab? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742348144a2457944.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论