1

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

2 Answers2

1

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.

Shiladitya
  • 12,003
  • 15
  • 25
  • 38
  • Hello, yes exactly, good support, the only problem with this code, visited link keeps white color –  Aug 28 '17 at 09:48
  • For changing color of visited link `.list-group-item-action:visited {background: #95f507;}` – Shiladitya Aug 28 '17 at 09:50
  • Sorry for mistake, I mean clicked button keeps color blue not visited. –  Aug 28 '17 at 09:56
  • `.list-group-item-action:active {background: #95f507;}` – Shiladitya Aug 28 '17 at 09:58
  • well, not sure what I'm doing wrong, code works perfectly on the local load, but when I uploaded html and overwrite updated bootstrap.min.css to my host, color is same default –  Aug 28 '17 at 10:08
  • Don't update `bootstrap.min.css`, keep a separate custom `css` file with all your `CSS`. Load custom `css` file after `bootstrap.min.css`. – Shiladitya Aug 28 '17 at 12:21
0

jsfiddle link

.change-color .list-group-item:not(.active):hover {
  background-color: #00ff73 ;
  }
<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 change-color">
         <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>

In your question, before edit , it was not clear that you want to change the background, you said you want to change the color.Here is the edited answer.

Jayakrishnan
  • 1,295
  • 2
  • 13
  • 27
  • Hello, I've tried this, bit it changes whole visual configuration of page, and does not changes active button link color here https://i.stack.imgur.com/vTa8e.png –  Aug 27 '17 at 21:16
  • I dont understand what u are saying , but if `a` is affrecting the whole page use something lik `.list-group a` or add an additional class to `list-group` and use that class to change color eg. `.change-color a{color: #8cf1dd !important;}` . Here is a screenshot of my answer http://imgur.com/a/VIdeN , clearly the active button color is chaging. If you can be more specific it would be healpful – Jayakrishnan Aug 27 '17 at 21:29
  • No, here is which color I want to change white to green, please check https://i.stack.imgur.com/AvZli.png –  Aug 27 '17 at 22:20