Michael Michael - 2 months ago 8
CSS Question

How to remove highlighting on anchor element?

I have this html elements anchors generated in

<ul>
element.



<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>


<ul class="nav pull-left">
<li style="display: inline-block;text-align: center;"><a class="" ui-sref="sites.list"><i class="glyphicon glyphicon-tree-conifer"></i> <br>sites</a></li>
<li style="display: inline-block;text-align: center;"><a class="" ui-sref="sitesDamages.sitesList"><i class="glyphicon glyphicon-exclamation-sign"></i> <br>events</a></li>
</ul>





When I navigate mouse on the links it highlighted.

Any idea how can I remove highlight?

Answer

One of Bootstrap's CSS rules is :

.nav > li > a:focus, .nav > li > a:hover {
    text-decoration: none;
    background-color: #eee;
}

Simply override it with your own, more specific rule:

.nav.pull-left>li>a:focus, .nav.pull-left>li>a:hover {
  background-color: transparent;
}

Example:

.nav.pull-left>li>a:focus,
.nav.pull-left>li>a:hover {
  background-color: transparent;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>


<ul class="nav pull-left">
  <li style="display: inline-block;text-align: center;"><a class="" ui-sref="sites.list"><i class="glyphicon glyphicon-tree-conifer"></i> <br>sites</a>
  </li>
  <li style="display: inline-block;text-align: center;"><a class="" ui-sref="sitesDamages.sitesList"><i class="glyphicon glyphicon-exclamation-sign"></i> <br>events</a>
  </li>
</ul>