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

190
Visualizações
Hovering not working while displaying an element on hovering another button

Intro

I am having a color palette. I wanted to display a tooltip whenever I hover that button. But when I hover over them , it is not.

I am using ReactJS and css for styling.

So this is the color palette and I want to display the tooltip whenver someone hovers any button.

cp

Now I followed upto 2nd answer here. But it is not working.

Code

App.js

themeList.map((t, k) => (
      <button
        key={k}
        id="theme_color_btn"
        data-theme={t}
        onKeyDown={this.keyboardNavigation}
        className={`theme-button bg-${t}-500${theme === t ? " is-active" : ""}`}
        onClick={this.changeTheme}
      >
        <div
          id="tooltip"
          className={`bg-${t}-100 absolute text-${t}-900 text-sm p-1 rounded-md ring-1 ring-purple-900 z-10 mt-3 transition-transform capitalize `}
        >
          {t}
        </div>
      </button>

where const themeList = [ "indigo", "yellow", "red", "purple", "pink", "blue", "green", ]; index.css

#theme_color_btn{
  display:block;
}

#theme_color_btn:hover + #tooltip{
  display:block; 
  z-index:5;
  background-color:gray;
}

#tooltip {
  display:none ;
}

Instead,no tooltips are displaying on hover.

For Full code refer index.css and App.js files here

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

0

Just remove the plus

#theme_color_btn:hover #tooltip{
   display:block; 
   z-index:5;
   background-color:gray;
 }

Hope this works

about 4 years ago · Juan Pablo Isaza Relatório

0

You wrote #theme_color_btn:hover + #tooltip but the + operator is used for "the next element" but #tooltip is inside #theme_color_btn ...

So you should write something like

#theme_color_btn:hover #tooltip

or

#theme_color_btn:hover > #tooltip

Look here: Css selectors

about 4 years ago · Juan Pablo Isaza Relatório

0

Use this css structure. This will work for sure

#theme_color_btn:hover{
&#tooltip{
  display:block; 
  z-index:5;
  background-color:gray;
}
}

#tooltip {
  display:none ;
}
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