导航栏升级至 Bootstrap 5

问题描述 投票:0回答:1

嗨,我需要将我的页面从 bootstrap 4.6.0 升级到 bootstrap 5.x.x

一旦我将 data-toggle 升级到 data-bs-toggle,活动选项卡就会停止工作,即无论我按多少个选项卡,第一个选项卡始终保持活动状态。 (选项卡内容仍然发生变化)

CSS .nav-tabs { 底部边距:-1px; }

        .nav-tabs > li.active {
            border-left: 1px solid #0094ff;
            border-right: 1px solid #0094ff;
            border-top: 1px solid #0095ff !important;
            box-shadow: -4px 4px 4px 0 rgba(0, 0, 0, 0.1);
        }

        .nav-tabs > li:not(.active) {
            border-bottom: 1px solid #0094ff;
        }

    .tab-content:before {
        width: 100%;
        background: #fff;
        height: 8px;
        content: "";
        display: block;
        position: relative;
        top: 0px;
        border-left: solid 1px #ddd;
        border-right: solid 1px #ddd;
    }

    .tab-content {
        padding-top: -10px !important;
    }

    .nav-tabs > li.active > a {
        -webkit-box-shadow: none !important;
        box-shadow: none !important;
        margin-right: 0 !important;
    }

HTML

<div class="col-lg-12">
                                    <ul class="nav nav-tabs" id="type-nav">
                                        <li id="liTabLinkID" class="active">
                                            <a href="#tab-linkid" class="clsLinkSel" data-toggle="tab" aria-expanded="true" style="color: #333"><i class="fal fa-bars"></i>&nbsp;&nbsp;Link ID(s) </a>
                                        </li>
                                        <li id="liTabRoute" class="">
                                            <a href="#tab-route" class="clsLinkSel" data-toggle="tab" aria-expanded="false" style="color: #333"><i class="fas fa-road"></i>&nbsp;&nbsp;Route </a>
                                        </li>
                                        
                                    </ul>
                                    <div class="tab-content" id="query-type-tabs">
                                        <div class="tab-pane top-tab-pane active" id="tab-linkid" style="padding: 20px 10px;border-left: solid 1px #ddd;border-right: solid 1px #ddd">
                                            <div>
                                                <div style="float: left">
                                                    <label><b>Links: </b></label>&nbsp;&nbsp;<span id="spnLinkCnt">0</span>
                                                </div>
                                                <div style="float: left; margin-left: 20px; padding-top: 1px">
                                                    <a href="#" onclick="FitToBounds(); return false" class="clsLinkIcons" style="margin-right: 7px"><i class="far fa-expand" title="Fit To Bounds"></i></a><a href="#" onclick="ViewLinkIDs(); return false" class="clsLinkIcons" style="margin-right: 7px"><i class="far fa-search" title="View Link ID's"></i></a><a href="#" onclick="OpenAddLinkIDs(); return false" style="margin-right: 7px"><i class="far fa-plus" title="Add Link ID's manually"></i></a><a href="#" onclick="ClearLinkIDs(); return false" class="clsLinkIcons" style="margin-right: 7px"><i class="far fa-trash" title="Clear Selection"></i></a>
                                                </div>
                                                <div style="float: left">
                                                    <label id="linkIDReq" style="color: #F00; display: none; margin-left: 10px">* required</label><a class="clsInfo"><i class="fas fa-question-circle"></i></a><div class="tooltiptext">Click on the map to select/deselect links.</div>
                                                </div>
                                                <div style="clear: both"></div>
                                            </div>
                                            <div id="seldeets">
                                                <!-- Holds selection info (table?)-->
                                            </div>
                                        </div>
                                        <div class="tab-pane top-tab-pane" id="tab-route" style="padding: 20px 10px; border-left: solid 1px #ddd; border-right: solid 1px #ddd">
                                            <div class="clsSelStateDiv">
                                                Select a State on the top-left
                                            </div>
                                            <div class="clsStateDiv" style="display: none">
                                                <label><b>Route:</b></label>&nbsp;&nbsp;<select id="selRoute" onchange="ShowRoute()" class="form-control" style="display: inline-block; width: 250px"></select>&nbsp;&nbsp;&nbsp;<a id="aRouteBounds" href="#" onclick="FitToRouteBounds(); return false" style="margin-right: 7px; display: none"><i class="far fa-expand" title="Fit To Bounds"></i></a><label id="routeReq" style="color: #F00; display: none; margin-left: 5px">  * required</label><a class="clsInfo"><i class="fas fa-question-circle"></i></a><div class="tooltiptext">Routes can be created in <b>Routing > Route Builder</b> on the side menu, or by clicking the <i>manage routes</i> link.<br /><br />Results can be ordered by the link sequence along the route.</div><a href="/routing/dataroutes" style="margin-left: 15px">manage routes</a>
                                            </div>
                                        </div>

 </div>
                                </div>
bootstrap-5 nav listitem
1个回答
0
投票

.active
类将添加到
a
标签,而您的自定义样式则以
li
元素为目标。

因此,将您的选择器全部更改为目标

a
标签:

而不是:

.nav-tabs > li.active {

等等,使用:

.nav-tabs > li > a.active {

自始至终。

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
<style>
  .nav-tabs {
    margin-bottom: -1px;
  }
  
  .nav-tabs>li>a.active {
    border-left: 1px solid #0094ff;
    border-right: 1px solid #0094ff;
    border-top: 1px solid #0095ff !important;
    box-shadow: -4px 4px 4px 0 rgba(0, 0, 0, 0.1);
  }
  
  .nav-tabs>li>a:not(.active) {
    border-bottom: 1px solid #0094ff;
  }
  
  .tab-content:before {
    width: 100%;
    background: #fff;
    height: 8px;
    content: "";
    display: block;
    position: relative;
    top: 0px;
    border-left: solid 1px #ddd;
    border-right: solid 1px #ddd;
  }
  
  .tab-content {
    padding-top: -10px !important;
  }
  
  .nav-tabs>li.active>a {
    -webkit-box-shadow: none !important;
    box-shadow: none !important;
    margin-right: 0 !important;
  }
</style>
</head>

<body>
  <div class="col-lg-12">
    <ul class="nav nav-tabs" id="type-nav">
      <li id="liTabLinkID" class="active">
        <a href="#tab-linkid" class="clsLinkSel active" data-bs-toggle="tab" aria-expanded="true" style="color: #333"><i class="fal fa-bars"></i>&nbsp;&nbsp;Link ID(s) </a>
      </li>
      <li id="liTabRoute" class="">
        <a href="#tab-route" class="clsLinkSel" data-bs-toggle="tab" aria-expanded="false" style="color: #333"><i class="fas fa-road"></i>&nbsp;&nbsp;Route </a>
      </li>
    </ul>
    <div class="tab-content" id="query-type-tabs">
      <div class="tab-pane top-tab-pane active" id="tab-linkid" style="padding: 20px 10px;border-left: solid 1px #ddd;border-right: solid 1px #ddd">
        <div>
          <div style="float: left">
            <label><b>Links: </b></label>&nbsp;&nbsp;<span id="spnLinkCnt">0</span>
          </div>
          <div style="float: left; margin-left: 20px; padding-top: 1px">
            <a href="#" onclick="FitToBounds(); return false" class="clsLinkIcons" style="margin-right: 7px"><i class="far fa-expand" title="Fit To Bounds"></i></a>
            <a href="#" onclick="ViewLinkIDs(); return false" class="clsLinkIcons" style="margin-right: 7px"><i class="far fa-search" title="View Link ID's"></i></a><a href="#" onclick="OpenAddLinkIDs(); return false" style="margin-right: 7px"><i class="far fa-plus" title="Add Link ID's manually"></i></a><a href="#" onclick="ClearLinkIDs(); return false"
              class="clsLinkIcons" style="margin-right: 7px"><i class="far fa-trash" title="Clear Selection"></i></a>
          </div>
          <div style="float: left">
            <label id="linkIDReq" style="color: #F00; display: none; margin-left: 10px">* required</label><a class="clsInfo"><i class="fas fa-question-circle"></i></a>
            <div class="tooltiptext">Click on the map to select/deselect links.</div>
          </div>
          <div style="clear: both"></div>
        </div>
        <div id="seldeets">
          <!-- Holds selection info (table?)-->
        </div>
      </div>
      <div class="tab-pane top-tab-pane" id="tab-route" style="padding: 20px 10px; border-left: solid 1px #ddd; border-right: solid 1px #ddd">
        <div class="clsSelStateDiv">
          Select a State on the top-left
        </div>
        <div class="clsStateDiv" style="display: none">
          <label><b>Route:</b></label>&nbsp;&nbsp;
          <select id="selRoute" onchange="ShowRoute()" class="form-control" style="display: inline-block; width: 250px"></select>&nbsp;&nbsp;&nbsp;<a id="aRouteBounds" href="#" onclick="FitToRouteBounds(); return false" style="margin-right: 7px; display: none"><i class="far fa-expand" title="Fit To Bounds"></i></a>
          <label id="routeReq" style="color: #F00; display: none; margin-left: 5px"> * required</label><a class="clsInfo"><i class="fas fa-question-circle"></i></a>
          <div class="tooltiptext">Routes can be created in <b>Routing > Route Builder</b> on the side menu, or by clicking the <i>manage routes</i> link.
            <br />
            <br />Results can be ordered by the link sequence along the route.</div><a href="/routing/dataroutes" style="margin-left: 15px">manage routes</a>
        </div>
      </div>
    </div>
  </div>

© www.soinside.com 2019 - 2024. All rights reserved.