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

189
Visualizações
How to scope the css properties of <style> tag within a svg?

I have a <style> tag inside a svg image with background-color property set to white. And I am dynamically adding this svg to the HTML. As the background-color is set to white, all other svgs on the webpage are inheriting this property which is unwanted. It seems the properties are applied globally, but I want to scope the property to this single svg or this single div

Earlier there was scope attribute for <style> which is now removed. How can I achieve this, specially in angular. Angular view encapsulation is not working in this case.

<div class="svg-image">
    <svg>
        <style>
        svg {
            background-color: white;
        }
        </style>
        <g>
        .
        .
        </g>
    </svg>
</div>

Edit: A similar question is answered here

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

0

apply custom class to your svg as folows,

app.component.html

<div class="svg-image">
    <svg class="svg-background-white">
        <g>
        .
        .
        </g>
    </svg>
</div>

app.component.css

.svg-background-white {
  background-color: white;
}
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