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

303
Visualizações
How to make error popup box appear to the right instead of above

I have this HTML element that creates a popup. I want to use this popup to show an error message in my form when the user enters invalid data. The problem with the popup is that it appears on top of the form input and there is a little arrow at the bottom that is pointing to the form.

HTML-

<div class="popup" onclick="myFunction()">
    <span class="popuptext" id="myPopup">{{ error }}</span>
</div>

JS-

function myFunction() {
  let popupTxt = document.getElementById("myPopup");
  popupTxt.classList.add("hide");
}

CSS-

      /* Popup container - can be anything you want */
      .popup {
        position: relative;
        display: inline-block;
        cursor: pointer;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
      }
      
      /* The actual popup */
      .popup .popuptext {
        /* visibility: hidden; */
        width: 160px;
        background-color: #555;
        color: #fff;
        text-align: center;
        border-radius: 6px;
        padding: 8px 0;
        position: absolute;
        z-index: 1;
        bottom: 125%;
        left: 50%;
        margin-left: -80px;
      }
      
      /* Popup arrow */
      .popup .popuptext::after {
        content: "";
        position: absolute;
        top: 100%;
        left: 50%;
        margin-left: -5px;
        border-width: 5px;
        border-style: solid;
        border-color: #555 transparent transparent transparent;
      }
      
      /* Toggle this class - hide and show the popup */
      .popup .hide {
        visibility: hidden;
        -webkit-animation: fadeIn 1s;
        animation: fadeIn 1s;
      }
      
      /* Add animation (fade in the popup) */
      @-webkit-keyframes fadeIn {
        from {opacity: 0;} 
        to {opacity: 1;}
      }
      
      @keyframes fadeIn {
        from {opacity: 0;}
        to {opacity:1 ;}
      }

What I need help with, is finding out how to move the small arrow to the left of the popup box so it's pointing at the input field when the popup box is to the right.

This is what it looks like currently. enter image description here

I need the error popup and arrow on the right of input and pointing to the input because I will add another for hostname input and don't want anything covered by the popup.

enter image description here

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

0

I'm going to take a shot in the dark, can you try the below CSS and let me know how it goes. It's difficult to predict without a working sample

/* The actual popup */    
.popup .popuptext {
  /* visibility: hidden; */
  max-width: 160px;
  background-color: #555;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 8px 0;
  position: absolute;
  z-index: 1;
  bottom: 50%;
  left: 100%;
  transform: translateY(50%);
}

/* Popup arrow */
.popup .popuptext::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translateX(-100%) translateY(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: transparent #555 transparent transparent;
}
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