What is the best way to display a popup on the right side when hovering?

I currently have a situation where a popup appears at the top when a user hovers over a link or text. However, the issue is that the popup is not fully visible on the screen. The top part of the popup seems to be hidden in the browser. My application uses twitter-bootstrap. Is there a way to make the popup appear on the right side of the element rather than on top?

function displayPopup(element) {
  elements = $(".popuptext")
  $.each(elements, function(i, e) {
    e.classList.remove("show");
  })
  popup_id = $(element).attr("data-popup-id")
  var popup = document.getElementById(popup_id);
  popup.classList.add("show");
}

function hidePopup(element) {
  popup_id = $(element).attr("data-popup-id")
  var popup = document.getElementById(popup_id);
  popup.classList.remove("show");
  popup.classList.add("hide");
}
/* 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: 350px;
  background: #ffffff;
  color: #585858;
  text-align: center;
  border-radius: 6px;
  border: solid 1px black;
  padding: 8px 0;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  /*left: 100px;*/
  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 .show {
  visibility: visible;
  -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;
  }
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="popup">
  <a href="/my-link" data-popup-id="popup-c5e1e2c5" onmouseenter="displayPopup(this)">Hover Over this text</a>
  <span class="popuptext show" data-popup-id="popup-c5e1e2c5" id="popup-c5e1e2c5" onmouseleave="hidePopup(this)">
        My Entire content
      </span>
</div>

Your assistance in solving this issue would be greatly appreciated. Thank you.

Answer №1

To tackle this using HTML:

<button type="button" class="btn btn-secondary" data-container="body" data-toggle="popover" data-placement="right" data-content="Content for the popover.">
  Popover on right
</button>

If you prefer solving it with JS:

$('#showPopup').popover('right')

You can delve deeper into Popovers within the bootstrap docs

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The initial $http POST in Angular ends up hitting the error path within the .then function despite the successful execution of the

Something strange is happening to me. This peculiar behavior occurs only on the initial POST request. However, when I resubmit the form, the subsequent requests work perfectly fine. The first $http post call leads to the error function in .then, even thou ...

What is the solution to resolving the error in Travis CI stating "Installation failed - version 13.7.0. It appears that the remote repository may be

Struggling to configure a basic JS project with Travis CI, but encountering consistent errors. The job log indicates an issue with installing the specified Node version during NVM installation. I have experimented with altering the Node version and confi ...

Guide for positioning buttons in front of an image using HTML and CSS

I need assistance placing buttons in specific positions above an image carousel using HTML and CSS code. Despite researching various resources, I am unable to resolve this issue. This is the HTML implementation: <!-- Image where buttons should be placed ...

In React (Next.js), the act of replacing a file is performed instead of adding a file

I kindly request a review of my code prior to making any changes. const test = () => { const [files, setFiles] = useState ([]); //I believe I need to modify the following statement. const handleFile = (e) => { const newFiles = [] for (let i= ...

Choosing all the checkboxes in a table by row using Jquery

I need a script that can selectively check checkboxes inside each table row. The solution provided in the reference post checks all checkboxes inside the table, but I specifically want to target checkboxes row by row. Reference post: Jquery select all ch ...

What steps can be taken to resolve the field error problem in Django?

While attempting to move from the list page to the detail page, I encountered an error related to a field error. To address this, I added an empty Slug field in the models, but it resulted in a page not found error. https://i.sstatic.net/LCptK.png #urls ...

What is the best way to add an image to a SVG placeholder?

This is all unfamiliar territory for me. I am experimenting with the Bootstrap template named "Carousel" as my starting point, utilizing Bootstrap 5.3.2. Here is the link to the Carousel example Everything seems fine so far. However, I am struggling to l ...

Obtain the present location of the cursor within the TinyMCE editor

Despite various attempts, I have struggled to determine the current cursor position inside TinyMCE. My goal is to implement a change control feature that captures the starting point of text entry within the TinyMCE "textarea," allowing me to save the ente ...

Ways to send a POST variable to PHP without refreshing the webpage

Is there a way to pass a simple variable from a text-box on a different page to PHP without reloading it? I've been informed that Ajax is required for this task, but I'm unsure of how to go about implementing it. Can someone provide me with a sam ...

Tips for ensuring the safety of your AJAX requests when using PHP and jQuery

Identifying the Challenge Lately, I have been exploring various AJAX methods to send data to a server for processing and storage in a MySQL database. The backend script that handles the AJAX request, api.php, is equipped with PHP's PDO prepared state ...

The Cordova minification tool fails to compress files within the browser platform

I recently installed the cordova-minify plugin to compress the javascript code in my Cordova app. When I tried running the command: cordova build browser An output message appears: cordova-minify STARTING - minifying your js, css, html, and images. ...

Tips for maximizing website performance on touch-enabled devices

When using a touch device such as an iPhone, iPad, or Android device, it can be challenging to accurately tap on small buttons with your finger. So far, there is no universal method in CSS media queries to detect touch devices. As a workaround, I check if ...

Manipulate array of observable data structure in Angular using RxJs filter function

I am working on filtering observable nested arrays in Angular using the filter function in combination with the pipe function of the RxJs library. Inquiry: I am looking to display only categories with surveys conducted on a specific date. Simplified scen ...

Delay the parsing of JavaScript in Rails 3.1 using nginx and unicorn

Currently, my project is running on rails 3.1 + nginx + unicorn on a Linode VPS with 512 MB of RAM and Ubuntu 10.04 64-bit, using MongoDB. I recently received an alert from Google Pagespeed regarding my production server, as shown in the image below: All ...

Guide to verifying the update of user information with sweet Alert on ASP MVC

I'm currently working on an ASP MVC web application that involves using stored procedures with SQL Server. My goal is to implement a confirmation alert (Sweet Alert) to confirm the data update for a logged-in user. The code for editing works fine wi ...

One web page featuring various query_posts

I'm in the process of developing a new template page for a WordPress theme that will feature 5 distinct "modules" embedded within the page's content section. These modules are designed to display the latest 4 posts from different categories, simi ...

A guide to sending epoch time data to a backend API using the owl-date-module in Angular

I have integrated the owl-date-time module into my application to collect date-time parameters in two separate fields. However, I am encountering an issue where the value is being returned in a list format with an extra null value in the payload. Additiona ...

Troubles encountered while implementing crypto-js in Parse Cloud Code for an iOS mobile app

For my iOS app, I have implemented Parse as the backend and want to ensure the data transmitted between Parse and the device is encrypted. To achieve this, I have turned to Parse Cloud Code for server-side encryption and decryption of all data exchanges. ...

Problem encountered when attempting to store an email address containing a "%" symbol

Hello, I am facing an issue with storing data from the frontend in MySQL DB and then retrieving it to the frontend. After updating the email address and saving it, it gets saved as abs%gmail.com instead of [email protected]. The strange thing is that ...

Transferring information from Node.js to HTML with the help of EJS template engine

Below is the Server Side code I am using: app.set('view engine', 'html'); app.engine('html', require('ejs').renderFile); app.use(express.static('views')); app.use(bodyParser.urlencoded({extended:true})); a ...