Issue with Bootstrap 5 tooltip placement at the top when the page is scrolled

Hey there, I've been facing an issue with tooltips in Bootstrap specifically when the placement is forced to "top." Currently, I am using version 5.1.3.

I attempted to create a code snippet to showcase the problem, but unfortunately, it's not replicable on CodePen. So instead, I'll share a code here along with a sample video.

function initializeTooltips() {
  var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
  tooltipTriggerList.forEach(function(tooltipTriggerEl) {
    return new bootstrap.Tooltip(tooltipTriggerEl)
  });
}

initializeTooltips();
.section {
  padding-top: 500px;
}
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0a6865657e797e786b7a4a3f243b2439">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1d7f7272696e696f7c6d5d28332c332e">[email protected]</a>/dist/js/bootstrap.bundle.js"></script>

<div class="section">
  <div class="row">
    <div class="col-12 text-center mt-5 pt-5">
      <button type="button" class="btn btn-secondary" id="test-btn" data-bs-toggle="tooltip" data-bs-placement="top" title="Tooltip with button">
                Tooltip on top
            </button>
    </div>
  </div>
</div>

Every time I scroll the page slightly downwards to view the button and hover my mouse over it, the tooltip pops up at the top with a gap equivalent to the scroll position.

https://i.sstatic.net/Gcqa5.gif

I experimented with various tooltip options like "boundary" and "container," but they didn't seem to alleviate the issue much.

Do you have any suggestions on how I can resolve this? Let me know your thoughts!

Answer №1

The issue I encountered was due to an oversight in the primary application template.

I neglected to include:

<!DOCTYPE HTML>

at the beginning of the HTML file. This seemingly minor error resulted in a major problem. Although the solution was straightforward, it required days of troubleshooting! Hopefully, this explanation will benefit others facing a similar issue.

Answer №2

Big shoutout to Ivan for the solution that saved me! I was having issues with tooltips not displaying properly within a table in Joomla, sometimes only showing up when I scrolled or not at all. Turns out, my problem stemmed from messing up the doctype declaration in my Joomla template by placing a stylesheet link before it. Simply moving that line up in the template resolved all my issues.

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

Incrementing numbers with jQuery append autoincrement

I am working with a dynamic list of input fields, each one with a unique incremental name. Here's an example structure... <input type="text" name="values[0]" value="some text"> <input type="text" name="values[1]" value="some other text"> ...

When using ng-repeat with an array, not all array values are repeated

I have a basic angular block that looks like this <script> function simpleList($scope){ $scope.addItem = function(){ $scope.items.push($scope.newItem); } $scope.items = ["apple", " ...

Adjusting Chrome Zoom to 100% with Selenium in C#

I've been trying to use this code in Selenium with C# to adjust the zoom level of the Chrome browser to 100% using JavaScript. However, it doesn't seem to be working as expected. Can someone please assist me with this issue? var js = ((IJavaScri ...

What is the best way to access the tooltip text in Reddit?

Currently, I am in the process of developing a Selenium web scraping tool specifically for Reddit. However, I am encountering some challenges in extracting the timestamp displayed in the image. from selenium import webdriver from webdriver_manager.chrome i ...

Tips for extracting information from a select box that is dynamically populating

I have a dropdown menu displayed in the image below. It contains a "More..." option that, when clicked, loads the next ten data items. Subsequent clicks on "More" will load another set of ten data items each time until the entire list is loaded. How can I ...

The extension's script initiates without waiting for the entire page to finish loading

Recently, I have embarked on developing a chrome extension that requires waiting for a YouTube page to fully load before inserting a button into the existing code. Despite using getElementById() to locate the element, the script often completes execution b ...

Passing an extra variable to the callback function in AJAX and saving the XMLHttpRequest.response as a variable

Attempting to read a local file on the server using the standard loadDoc(url, cfunc) function, my goal is to: 1) Search for a specific string in the file (getLine()); 2) If possible, save that line to a variable. For point 1, I provide a string to the c ...

ways to add spacing between bootstrap columns

I am currently using Bootstrap 5 and I'm trying to create a row with 6 columns. I have added gutter in the row but for some reason, the spacing between the columns is not being applied. Can anyone help me figure out what I'm doing wrong here? Bel ...

Utilizing a potentially existing Angular service

Currently, I am engaged in a project using Angular that focuses on being highly modular. This means that different sections of the application can be enabled or disabled for various clients using Webpack. While this structure has been effective for me, I h ...

determining if a condition is vacant or occupied

Seeking assistance in determining if the array is empty or not. What are the conditions for this? An empty array appears as follows: [ { "readTime": "2019-09-09T15:20:44.648599Z" } ] A non-empty array looks like this: [ { "d ...

Using React to dynamically assign a backgroundImage based on a JSON response

I am having an issue with retrieving data from my Wordpress API and displaying it in my react app. Specifically, I am struggling to set the post's featured image as a background-image for an element. Here is an example of the JSON response: { "id" ...

Attempting to implement a polygon-shaped button with material-UI and React framework

https://i.sstatic.net/Nlxrr.jpg This is a design I am experimenting with for the poly button above. I have tried various styling methods. Does anyone have any ideas? ...

Tips for selectively executing a script based on whether the DIV is within the viewport

I have a created a script as shown below: jQuery(function($) { $('.count').countTo({ from: 0, to: '400', speed: '3000', refreshInterval: 50, onComplete: func ...

A guide to extracting attribute values from HTML using Angular 4

I am currently working on an Angular 4 project where I needed to implement drag and drop functionality. To achieve this, I utilized the ng2-dragula plugin. Now, I have a new requirement which involves extracting the data-id attribute from each row after it ...

Press the Concealed Button Enclosed in a div Using Selenium with Python

Currently, I am in the process of automating the login on the Workday portal by utilizing Chrome WebDriver in Selenium. My main challenge lies in figuring out how to click on a hidden sign-in button with the following properties: <div class="css-1s ...

What is the best way to utilize an onClick on a button to update a value that is being utilized in a useEffect hook?

I am looking for a way to dynamically change the content displayed in this section without navigating to another page. I have two sets of data - one displaying all blogs and the other showing only blogs authored by "mario". How can I implement a button cli ...

Avoid using the AJAX function if an identical request is already in progress

I have set up an AJAX request within a JavaScript function. By using the setInterval method, this AJAX function runs every 5000 milliseconds. I am curious if there is a way to determine if the previous AJAX call is still in progress to prevent multiple si ...

I am working on an aspx page that includes a master page and I need to dynamically update the content within the ContentPlaceHolder asynchronously

In my ASPX page with a master page, I am looking to asynchronously update the ContentPlaceHolder section. My initial thought was to use an update panel, where upon user submission, the update panel would refresh with the solution. Alternatively, I am consi ...

Exploring HTML5 video playback in AngularJS

When I use this code: <video id="video" class="video-js vjs-default-skin" controls width="640" height="264"> <source src="http://localhost:3000/files/public/photos/Let-her-go.mp4" type='video/mp4' /> <p class="v ...

Django No Reverse Match Error - All Functions Are Failing

After spending countless hours troubleshooting, I have encountered an issue where the HTML form action in a newly rendered page is causing the page not to load properly. Surprisingly, this specific line of code seems unrelated to the rendering process itse ...