css - 在 bootstrap 中突出显示事件 li

标签 css twitter-bootstrap

      <div class="col-xs-6 col-sm-3 sidebar-offcanvas" id="sidebar" role="navigation">
        <div class="list-group">
            <a href="#" class="list-group-item">Home</a>
          <a href="#" class="list-group-item active">Quem-somos</a>
          <a href="#" class="list-group-item">FAQ</a>
        </div>
      </div><!--/span-->
    </div><!--/row-->

我上面有这段代码,我想用危险颜色突出显示当前页面,但是 .active 类在这段特定代码中是蓝色的。

我已经尝试在我的样式表中设置:

.active {
 background-color: red;
}

但没有效果

最佳答案

尽管指定 !important 会起作用,但这是一种不好的做法,因为它会停止 css 级联,并且可能会导致比它修复的问题更多的问题。您需要做的就是更加具体地选择您的选择器。

.list-group a.active { background-color: red;}

查看我的 Example

关于css - 在 bootstrap 中突出显示事件 li,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26535339/

相关文章:

html - 如何从它的父元素的中心缩放 <i> 标签?

html - 使用框架会使网站变重吗?

javascript - 检查时 Bootstrap 按钮类重复,我该如何解决这个问题?

ruby-on-rails - rails + Bootstrap : How to iterate over collection of items with multiple items per row

jquery - 使用 JQuery 和 css 显示图像背景位置 : jitters (except firefox) + percentage conundrum

HTML 选择框 - 如何强制禁用的选择保持其最宽的子宽度?

HTML/CSS : Bottom of body cut off

css - Bootstrap CSS - 如何使搜索表单与其他导航栏元素保持内联?

twitter-bootstrap - 带有 Bootstrap 3 的 Angular Dialog 指令

asp.net-mvc - Bootstrap 列溢出