简体   繁体   English

Bootstrap 3导航丸,活动类仅在单击分配的元素后才起作用

[英]Bootstrap 3 nav-pills, active class works only after I click assigned element

I have following code for nav-pills component: 我对nav-pills组件有以下代码:

  <ul id="steps" class="nav nav-pills form-steps">
    <li class="active"><a data-toggle="pill" href="#options"></a></li>
    <li><a data-toggle="pill" href="#payments"></a></li>
  </ul>

And this is my tab-content just to make sure that href and id are equal: 这是我的tab-content只是为了确保hrefid相等:

  <div class="tab-content">
    <div class="tab-pane fade in active" id="options">
      <%= render 'options' %>
    </div>
    <div class="tab-pane fade" id="payments">
      <%= render 'payments' %>
    </div>
  </div>

This is how the look of active a is made (basically it's just a circle filled with special color): 这是主动a外观的方式(基本上只是一个充满特殊颜色的圆):

.form-steps > li.active > a {
    background-color: #931f2a;
}

And here's code for a regular a : 这是常规a的代码:

.form-steps > li > a {
    border: 2px solid #931f2at;
    height: 30px;
    width: 30px;
    border-radius: 100%;
}

I suppose that by adding .active class to corresponding li element makes a element filled with color, but it doesn't when I open modal where this component is placed for the fist time, to activate this color I must click on the link, right after that my element is filled. 我想,通过增加.active类对应的li元素,使a充满色彩元素,但是当我打开模态此组件放置拳头时,激活这种颜色,我必须点击链接,它不会吧之后,我的元素就被填满了。 When I open modal for the second time after I click on another link, I see correct behavior, ie .active class is filled with color. 当我单击另一个链接后第二次打开模式时,我看到正确的行为,即.active类充满了颜色。 It's an SPA and I have another nav-pills like this with exact markup and it works just fine and I don't quite understand why this behavior doesn't work on second nav-pills . 这是一个SPA,我还有另一个带有精确标记的nav-pills ,它的工作原理还不错,而且我不太理解为什么这种行为不适用于第二个nav-pills I double checked that class names and ids don't repeat each others and I am sure that no custom js was involved into this. 我再次检查了类名和ID是否不会重复,并且我确定没有自定义js参与其中。 Can you please give me a direction to inspect what I did wrong? 您能给我一个方向去检查我做错了什么吗? Thanks in advance! 提前致谢!

尝试添加以下CSS:

.form-steps > li.active > a:focus { background-color: #931f2a; }

.form-steps > li.active > a:active { background-color: #931f2a; }

.form-steps > li.active > a:visited { background-color: #931f2a; }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM