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

102
Visualizações
Can't override CSS directive with caret selector

I have an SVG file (inline in an HTML page) with about 60 buttons.

Each of them has two additional states, each of which has an ID of the form:

<g id="mov0-1"><!-- mouseover state -->
<g id="mod0-1"><!-- mousedown state -->

Initially the mouseover and mousedown states are hidden in CSS:

g[id^='mod'] { display: none; }
g[id^='mov'] { display: none; }

When there is a mouseover, the state should change, using this function:

var obj = document.getElementById('link' + c + '-' + x);
obj.addEventListener('mouseover', mov.bind(null, x, c), false); 
...
function mov(x, c){
  var obj_id = 'mov' + c + '-' + x;
  var obj = document.getElementById(obj_id);
  obj.style.display = 'block';
}

The above function fails. However, if I replace the CSS caret with a list of individual buttons, the function works:

g#mov1-0{display:none;}
g#mod1-0{display:none;}

Why is this happening?

Is there a way I can keep my elegant two-line solution that hides 120 buttons instead of having to list them all separately?

N.B. the SVG's are generated automatically by Adobe Illustrator, and I can't use CSS classes.

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

0

So it was a boneheaded mistake.

The parent objects also had ID's that began with mov and mot, so when I hid the unused buttons, I also hid their parent containers.

Lesson 1: be careful with wildcards.

Lesson 2: when something breaks, don't assume it's because of some elaborate technical thing instead of a stupid error.

Lesson 3: build a simple test case to reproduce the problem.

Renaming the parent containers (Illustrator layers) fixed the problem.

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