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

181
Visualizações
Change font color based on background image

I have a website where there are images moving around in the background and I would like the nav font to change based on the image color..

To get what I mean, just look at the '+' in this website nav https://www.atomomanagement.com/

Based on the image it either is white or black. I would like to do the same but I had no luck. I tried using mix-blend-mode: difference but it does not work

Can anyone help?

Kind regards

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

0

I felt I should post an answer to explain what is going on with OPs example.

Simply settings a fill: white on an SVG does not fully reproduce the desired result. OP's example also requires a parent div with mix-blend-mode: difference set as well.

You can actually reproduce this without any SVGs at all. You simply need an element with a color/fill of white, and a parent element with mix-blend-mode: difference. This has to do with how the blending mode of difference works with the color white over a background.

function _Swap() {
  document.querySelector(".backgroundDiv").style.background = (document.querySelector(".backgroundDiv").style.background == "rgb(0, 0, 0)") ? "rgb(255, 255, 255)" : "rgb(0, 0, 0)";
}
.backgroundDiv {
  background: #FFF;
  padding: 4em;
}

.test {
  mix-blend-mode: difference;
}

p {
  color: #FFF;
}
<div class="backgroundDiv">
  <div class="test">
    <p>This is a test</p>
  </div>
</div>
<input type="button" value="Swap Background Color" onclick="_Swap()">

about 4 years ago · Juan Pablo Isaza Relatório

0

It is not changing. the path element in svg has this css attribute:

fill: white;

It is causing what you see. you can open it in devTools and remove that attribute and you can see the change then. to achieve what you want make a svg and add fill: white; to the path element.

Update:

I just found out this css property which was given to nav tag:

mix-blend-mode: difference;

It will revert the entire color of the element in the tag based on the bg.

essxtee answer was before my update. So the credit is his :)

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