-1

I can get to show a selected link, but when I click somewhere in the page, the highlight disappears. I'm also struggling to get the highlight to edges like the hover.

I've attached a piece of code and a picture for reference.

enter image description here

#sidebarContent a :ACTIVE, #sidebarContent a:FOCUS{
        background-color: Green;
        padding: 5px 10px; 
        /* margin-left:auto;
        margin-right:auto; */
        text-decoration: none;
        width: 120px;           
    }
Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
eldix_
  • 127
  • 4
  • 20

1 Answers1

2

If you use angular application (you added this tag) - you can use active class to mark your current route instead of using ::focus pseudo class.

  <a href="#/home" ng-class="{active: isActive('home')}">Home</a>
  <a href="#/about" ng-class="{active: isActive('about')}">About</a>

where:

$scope.isActive = function(path) {
    return $location.path() == '/' + path;
}

Please check this fiddle https://jsfiddle.net/vadimb/2waujx3m/

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
VadimB
  • 5,533
  • 2
  • 34
  • 48