user8456381 user8456381 - 2 months ago 14
CSS Question

Change color for active button of Bootstrap Links and Buttons component

Hello I use Bootstrap Links and buttons

I'm trying to changed the color for active button highlighting, which appears when the mouse is over the button, white by default to different color:

<div class="container">
<div class="row">
<div class="col-md-6 col-sm-12">
<div class="list-group">
<h2><a href="#" class="list-group-item active">
<strong>T E X T</strong></a>
<a href="page1.html" class="list-group-item list-group-item-action"> Link 1 </a>
<a href="page2.html" class="list-group-item list-group-item-action"> Link 2 </a>
</div>
</div>
</div>
</div>


I've tried it as it is shown in this answer to the same question whit css, because I don't have scss/bootstrap.scss in my assembly only _bootstrap-overrides.scss

So to the end of bootstrap.css:

a {color: #8cf1dd;}
a:hover {color: #e9d214;}


and into the
<head>
of HTML with Bootstrap Links and buttons component:

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<style>
.card .nav-link {color: #8cf1dd;}
.card .nav-link:hover {color: #e9d214;}
</style>


but color is same and I want something like this

Answer Source

Here you go with a solution https://jsfiddle.net/a29696xg/7/

.list-group-item-action:hover {background: #95f507;}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
    <div class="row">
      <div class="col-md-6 col-sm-12">
        <div class="list-group">
          <h2><a href="#" class="list-group-item active">
          <strong>T E X T</strong></a></h2>
           <a href="page1.html" class="list-group-item list-group-item-action"> Link 1 </a>              
            <a href="page2.html" class="list-group-item list-group-item-action"> Link 2 </a>                    
        </div>
      </div>
    </div>
</div>

In CSS if you target anchor tag, then all the anchor tag will get effected, rather target with a particular class .list-group-item-action.

For some reason, code isn't running in stackoverflow, but it's working fine in jsfiddle.

Hope this will help you.