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

202
Visualizações
Change color of text when div is transitioning through it

I want to implement a navbar element highlight using a div that moves (via transitions) to the selected element when you click on it.

But in addition, it should change the color of the text it passes through.

See this example (the red highlight is currently moving from "First" to "Second Text", coloring the text inside the highlight white):

highlight transition show-case

I've made a small codepen to showcase a solution I came up with, which utilizes position: absolute and overflow: hidden.

See here: https://codepen.io/JZ_CodePen/pen/JjMzpye

Is there a simpler / more professional way to implement this?

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

0

That is the best way. Using position: absolute and overflow: hidden is great. You are also using the onclick event of JavaScript, which makes it even better. One thing you could do is change the text-color of the text onclick, but then that would make the whole thing white instead of partially like you want.

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