Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

106
Visualizações
HTML color of active tab

I am creating a web based app, and I am using Spring and Angular. I am writing the front end in the Angular folder, and I have this HTML code to be on every page(app.component.html) - it is a menu:

<div class="topnav">
  <!-- Centered link -->
  <div class="topnav-centered">
  </div>
  <div class="topnav-right">
    <a routerLink="/home" >Home</a>
    <a routerLink="/login" >Login</a>
    <a routerLink="/register" >Register</a>
  </div>
</div>

And I have this as css so it is centered and looking all nice.

.topnav {
    position: relative;
    background-color: #333;
    overflow: hidden;
  }

.topnav a {
    float: left;
    color: #f2f2f2;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
    font-size: 17px;
  }

.topnav a:hover {
    background-color: #ddd;
    color: black;
  }

.topnav-right {
    float: right;
  }

How do I get it to change the color of the buttons(Home, Login, Register) when I am in the current page? (for ex. when I'm in Home page the button will be green, when in Login - it will be green)

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use routerLinkActive which will add a CSS class to the element when the route is active.

<div class="topnav">
  <!-- Centered link -->
  <div class="topnav-centered">
  </div>
  <div class="topnav-right">
    <a routerLink="/home" routerLinkActive="active-link">Home</a>
    <a routerLink="/login" routerLinkActive="active-link">Login</a>
    <a routerLink="/register" routerLinkActive="active-link">Register</a>
  </div>
</div>
.topnav-right a.active-link {
    color: #ff0000;
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda