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

123
Visualizações
CSS: Apply Filter of type URL() to all elements

I am trying to apply a filter to the body of my page using filter: url(#filter_id), but im not managing to make it work.

This is how im adding it to the styling:

document.body.style.filter = 'url("#filter_id")'

and this is how i am creating the filter

var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
svg.setAttribute("width","0" )
svg.setAttribute("height","0" )

var filter = document.createElement("filter");
filter.setAttribute("id","filter_id" )

var feColorMatrix = document.createElement("feColorMatrix")
feColorMatrix.setAttribute("type","matrix")
feColorMatrix.setAttribute("values","1 1 1 1 0 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0")

filter.appendChild(feColorMatrix)
svg.appendChild(filter)

document.body.prepend(svg)

this creates the filter element on the top of the body:

<filter id="filter_id">
<fecolormatrix type="matrix" values="1 1 1 1 0 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0"/>
</filter>

How can i apply it to the full page so that every element gets the color shift that i intend? For context, this is currently employed in a chrome extension im developing.

If i do other types of filters it works (applies to the full page)

document.body.style.filter = "blur(1px)"
about 4 years ago · Juan Pablo Isaza
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