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

141
Visualizações
How can I disable all CSS that can affect my widgets on another website?

I'm building JavaScript widgets that are supposed to be added onto other people's websites.

I style my widgets by dynamically adding a CSS to the pages they're on.

For example,

My CSS code below applies to a DIV inside my widget:

.myWidget { background-color: red; }

But a CSS file outside my own on a remote page might have:

div { border: 5px solid green; }

The CSS above would also apply to my widgets. How can I disable all other CSS outside my own?

Thanks

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

0

You could be Using shadow DOM

Shadow DOM MDN Web Docs

An important aspect of web components is encapsulation — being able to keep the markup structure, style, and behavior hidden and separate from other code on the page so that different parts do not clash, and the code can be kept nice and clean. The Shadow DOM API is a key part of this, providing a way to attach a hidden separated DOM to an element.

about 4 years ago · Juan Pablo Isaza Relatório

0

You can use the all shorthand property and the unset keyword to set each property's value to its initial value.

.myWidget {
  all:unset;
  background-color: red;
}

div {
  background-color:yellow;
}
<div class="myWidget">Hello World!</div>

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