Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

297
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!