gpt4 book ai didi

bootstrap-4 - 带有导航选项卡的 Bootstrap (4.3.1) 卡 - 我需要自动选择 "default"选项卡

转载 作者:行者123 更新时间:2023-12-01 19:28:10 25 4
gpt4 key购买 nike

我有一个引导卡,在这张卡中我有打开选项卡 Pane 的导航选项卡,我需要在用户到达页面时选择并打开第一个(默认)选项卡

<div class="container">
<div class="card">
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs" id="profileTab" role="tablist">
<li class="nav-item">
<a class="nav-link" id="tabMain" data-toggle="tab"
href="#profileMain" role="tab"
aria-controls="profileMain" aria-selected="true">Main</a>
</li>
.....
<div class="tab-content" id="profileTabsContent">
<div class="tab-pane fade" id="profileMain" role="tabpanel" aria-labelledby="tabMain">
<div class="card-body">
<table class="table table-sm table-hover table-bordered table-striped">

我在内容和标题中尝试了 aria-expanded aria-selectedaria-pressed 但没有区别

最佳答案

添加类active反对

  • 锚定类 nav-link<a class="nav-link active" id="tabMain" data-toggle="tab" href="#profileMain" role="tab" aria-controls="profileMain" aria-selected="true">Main</a>
  • div 类 tab-pane<div id="home" class="container tab-pane active">

工作片段:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>

<div class="container">

<div class="container">
<div class="card">
<div class="card-header">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#home">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#menu1">Menu 1</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#menu2">Menu 2</a>
</li>
</ul>
</div>
</div>
</div>

<!-- Tab panes -->
<div class="tab-content">
<div id="home" class="container tab-pane active"><br>
<h3>HOME</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
<div id="menu1" class="container tab-pane fade"><br>
<h3>Menu 1</h3>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<div id="menu2" class="container tab-pane fade"><br>
<h3>Menu 2</h3>
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam.</p>
</div>
</div>
</div>

关于bootstrap-4 - 带有导航选项卡的 Bootstrap (4.3.1) 卡 - 我需要自动选择 "default"选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59288876/

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