html - Bootstrap 侧边栏折叠菜单 :after

标签 html css twitter-bootstrap

我用 Bootstrap 制作了一个折叠菜单,效果很好,但我做不到,所以链接的颜色与按钮的颜色相同:

.collapse-link a:after {
  font-family: 'Glyphicons Halflings';
  content: "\e114";
  color: $white;
  background-color: black;
}

.collapse-link a.collapsed:after {
  content: "\e080";
  background-color: white;
}

我希望 class="collapse-link" 在右侧的按钮中获得与现在相同的背景颜色,因此当折叠时整个 div 将跟随按钮颜色并且什么时候不是,现在只有按钮获得背景颜色我想要标题:test3 和 test 获得旁边按钮的背景颜色。

jsfiddle:http://jsfiddle.net/Wc4xt/4377/

HTML:

<div class="sidebar">
  <div class="sidebar-wrapper">
    <ul class="sidebar-nav">
      <li>
        <i class="pull-left fa-lg fa fa-book" aria-hidden="true"></i>
        <div class="collapse-link">
          <a data-toggle="collapse" data-target="#collapseExample1" aria-expanded="false" aria-controls="collapseExample1">test3
          </a>
        </div>
        <div class="collapse in collapse-styled" id="collapseExample1">
          <i class="pull-left fa fa-lg fa-list" aria-hidden="true"></i>
          <a href="#">test List</a>
          <i class="pull-left fa fa-lg fa-list" aria-hidden="true"></i>
          <a href="#">Create</a>
        </div>
      </li>
      <li>
        <i class="pull-left fa fa-lg fa-book" aria-hidden="true"></i>
        <div class="collapse-link">
          <a data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">test
          </a>
        </div>
        <div class="collapse in collapse-styled" id="collapseExample">
          <i class="pull-left fa fa-lg fa-list" aria-hidden="true"></i>
          <a href="">link List</a>
          <i class="pull-left fa  fa-lg fa-list" aria-hidden="true"></i>
          <a href="">test</a>
        </div>
      </li>
    </ul>
  </div>
</div>

CSS:

.sidebar-wrapper {
  height: 100%;
  overflow-y: auto;
  background: #2f3f4d;
  -webkit-transition: all 0.5s ease;
  transition: all 0.5s ease;
}

.sidebar-nav li {
  text-indent: 22px;
  line-height: 60px;
  border-bottom: 1px solid #455b6f;
}

.sidebar-nav li a {
  display: block;
  height: 65px;
}

.collapse-link a:after {
  font-family: 'Glyphicons Halflings';
  content: "\e114";
  color: $white;
  background-color: black;
}

.collapse-link a.collapsed:after {
  content: "\e080";
  background-color: white;
}

最佳答案

添加以下 CSS 使其工作:

.collapse-link a.collapsed {  
  color: white;
}

a {
  text-decoration:none;
}

ul li {
  list-style:none;
}

同时检查: http://jsfiddle.net/mayankN/Wc4xt/4381/

关于html - Bootstrap 侧边栏折叠菜单 :after,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40654743/

相关文章:

javascript - 如何使用 Google 应用脚本一次上传多个文件到 Google Drive?

javascript - 如何将 Kinteic.js 中的以下代码转换为函数?

background-image - 如何淡化CSS中的框阴影?

CSS block 位置问题

css - Bootstrap : how to move form fields to their own lines in mobile view?

jquery - 使用 bootstrap on rails 设置缩略图路径

html - 使用 Google 的 reCaptcha 保护下载链接免受机器人攻击

Javascript:悬停元素,更改不相关元素中的类

html - 如何为输入字段提供完整的宽度和高度

css - 使用 Bootstrap 将元素排列为对(响应式)