使用 bootstrap 3,我自定义了一个列表组,如下所示:
<div class="list-group">
<a class="list-group-item list-group-item-mine"href="/path"><strong>Item 1</strong></a>
<a class="list-group-item list-group-item-mine"href="/path"><strong>Item 2</strong></a>
<a class="list-group-item list-group-item-mine"href="/path"><strong>Item 3</strong></a>
</div>
CSS
.list-group-item-mine {
background-color: #f1f9fb;
border-top: 1px solid #0091b5;
border-left-color: #fff;
border-right-color: #fff;
}
.list-group-item-mine a:hover {
background-color: red;
}
问题是,当鼠标悬停时,列表组项目仍默认变为灰色,而我需要它们变为红色。我怎样才能解决这个问题?
原文由 Karlom 发布,翻译遵循 CC BY-SA 4.0 许可协议
在父类中使用您的自定义类
.list-group-mine
而不是在子类中使用…它会让您更好地控制内部元素的样式堆栈片段