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

193
Visualizações
Removing a filter from image links, while applying filter to links in the same div?

I am using huerotate to change colors of my text links in my div, the problem is, it is also applying to my image links. I have tried removing them from images only(what I want) but I just can't figure it out. Any ideas? (I have made a JS to have a button to change colors on my design, and I want the text links to change when it is pressed, but not have the images change.)

.scontent {
    max-width: 100%;
    margin: 20px 0px;
    padding: 5px 5px 5px 10px;
}

.scontent a {
    color: var(--links);
    filter: hue-rotate(var(--hue-rotate));
}

.scontent a:hover {
    color: var(--links-hover);
    filter: hue-rotate(var(--hue-rotate));
}

.scontent a img {
    filter: none !important;
} 
about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

The thing is, you are applying filter to a, but clearing the filter on img. This is the case for :has pseudo-selector, but its currently in draft, so there is no Pure CSS Solution. You need to take help of JavaScript, to reset the hue-rotate filter on all a that has img inside it.

let imgArr = document.querySelectorAll('.scontent a img');

[...imgArr].forEach((img)=>{
  img.parentNode.style.filter = "hue-rotate(0deg)";
})
:root{
  --links: #ff0000;
  --hue-rotate: 90deg;
}
.scontent {
    max-width: 100%;
    margin: 20px 0px;
    padding: 5px 5px 5px 10px;
}

.scontent a {
    color: var(--links);
    filter: hue-rotate(var(--hue-rotate));
}

.scontent a:hover {
    color: var(--links-hover);
    filter: hue-rotate(var(--hue-rotate));
}
<div class="scontent">
  <a href="#">Text Link </a>
  <a href="#"><img src="https://picsum.photos/200/200" /> </a>
</div>

about 4 years ago · Santiago Gelvez 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