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

197
Visualizações
Change every same css property in a css file

In my CSS file, I have more classes and ids for the same color. I mean about "same color" is a visual thing.so, it can be "color" property also "background-color" and ".class:hover".

so same thing is a word like #33453

I want to change all #33453 in a CSS file with jquery. How can I do it?

my css file likes that:

<style>
.button-color, .button-border {
color:red;
border-color:#33453;
}

#background-color, button-background-color:hover {
background-color:#33453
}
</style>

I just found this:

$("body").children().each(function () {
    $(this).html( $(this).html().replace(/@/g,"$") );
}); 

it is so smilar what I want but how can I change "body" selector with css file?

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

0

CSS Variables to the rescue!

You can create CSS variables, whcih can be referenced throughout your stylesheet.

Write a root: at the start of your stylesheet. And then '--' at the front of your variable name.

:root {
  --main-color: #33453;
}

Then in your stylesheet you can reference the CSS variable with var().

.button-color, .button-border {
  color:red;
  border-color: var(--main-color);
}

#background-color, button-background-color:hover {
  background-color: var(--main-color);
}

You can also change this variable in a cascading way. So if you have...say...a "dark" section you can also add

.dark {
  --main-color: white;
}

And now anything with main-color inside of .dark will be different.

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