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

154
Visualizações
CSS/JS keep DIV hidden as default and open on click

I have a simple emoji picker and the ballon remains open as default when the page is refreshed, I can't find a way how to keep it close and only open the ballon when pressing a button.

HTML

<div class="container">                                                                            
      <div class="emoji-btn open"><img src='images/smileys.png' title='Smileys'>
       <!--this is the div I want to keep hidden till I click the button > -->  <div class="emoji-popup">
            <div class="emoji-wrapper"></div>
         </div>
      </div>
</div>

JS

emojibtn.addEventListener("click", function (e) {
   e.stopPropagation();
   this.classList.toggle("open");
});
document.body.addEventListener("click", function () {
   emojibtn.classList.remove("open");
});

CSS

.emoji-popup {
   position: absolute;
   top: -140px;
   left: 10px;
   height: 130px;
   width: 194px;
   background: #999;
   border-radius: 2px;
   text-align: left;
   overflow-y: auto;
   opacity: 0;
   pointer-events: none;
   transition: all 0.25s;
   box-sizing: border-box;
}

.emoji-wrapper {
   overflow: hidden;
   padding: 10px;
   box-sizing: border-box;
}
.emoji-popup .emoji-img {
   margin: auto;
   width: 30px;
   height: 30px;
   text-align: center;
   border-radius: 5px;
}

.emoji-popup .emoji-img:hover {
   background: rgba(0, 0, 0, 0.25);
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can add the property display: none; ( https://developer.mozilla.org/en-US/docs/Web/CSS/display), visibility: hidden(https://developer.mozilla.org/en-US/docs/Web/CSS/visibility) or opacity: 0; (https://developer.mozilla.org/en-US/docs/Web/CSS/opacity). Then onClick you can add the class open with the properties display: block (if it's a div), visibility: visible or opacity: 1.

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