Hide the tooltip when scrolling within an overflow container

Currently, I am utilizing Angular - Clarity to incorporate cards and tooltips.

To view the issue, kindly visit the following URL: https://stackblitz.com/edit/clarity-wio9hp

The problem lies in the tooltip being hidden within the card. Ideally, I want the tooltip to be displayed without being cut-off by the card. Additionally, the contents inside should have overflow scroll/auto functionality.

I have extensively searched for solutions to this issue, but unfortunately, none of them seem to work effectively for me.

Answer №1

.tooltip-content is set to have position: relative, which means it will always be displayed inside the card.

Another option is to show the tooltip based on the mouse position.

To display the tooltip outside the box, you can change the positioning to position: fixed.


.tooltip-content {
  position: fixed!important;
}

This will require some custom coding to ensure the tooltip appears in the right place. You can base its position on the mouse coordinates. For more information, check out this post: Angular 4 Observables mouse coordinates

By binding the element style top and left to the tooltip element, the tooltip will move along with your mouse cursor:

<span class="tooltip-content" [style.top]="mouseY + 'px'" [style.left]="mouseX + 'px'">
Keep in mind that additional styling may be needed for a polished display.

Take a look at: https://stackblitz.com/edit/clarity-aogelj In this example, the first tag demonstrates what I mean.

You can also retrieve the coordinates of the <a> element you are hovering over and position the tooltip using position: fixed along with top: elementY px and left: elementX px. Methods for accessing the DOM element are explained here: How to get dom element in angular 2

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

What is the best way to prevent centered elements from overflowing the screen using only CSS?

I have noticed that in my code, when I add a lot of elements, some of the content overflows off the screen. It's acceptable if the content goes off the bottom of the screen as it is still accessible. However, I want to prevent it from going off the to ...

Issue with Font Requests in Browsers when Using Angular 10 and SCSS with @font-face

I have a project built with Angular 10 that utilizes SCSS for styling. In my _typography.scss file, I have defined some @font-face rules pointing to the font files located in the assets/fonts directory. However, when I run the application, the browser does ...

The appearance of the webkit-scrollbar is not reflecting the intended style

I have successfully created a wrapper for a styled scrollbar in React JS - import styled from '@emotion/styled'; export const ScrollbarWrapper = styled.div(() => ({ maxHeight: '65vh', overflowY: 'auto', '*::-web ...

What exactly does original-title refer to in HTML coding?

I have been searching extensively, but I cannot find any information that explains the meaning and proper usage of the original-title in HTML code. I am unsure if original-title is a Tag or Attribute in HTML, and if it is the same as title? I came across ...

How can you enable a button to be clicked from within a drawer?

Hey there, I've got a div that toggles hide/show like a drawer when clicked. When the drawer is in show state, it contains a button. How can I make the button clickable without toggling the drawer? Any ideas on this?! `zIndex` doesn't seem to be ...

The compatibility of IE9 with tables and the use of display: block

When optimizing my site for low-width mobile devices, I adjust the display property of various table elements such as tr, td, and th to block in order to stack them vertically. This technique helps wide tables to show all their content without overflowing ...

React.js doesn't seem to be picking up any CSS files

I recently developed an app and encountered an issue with loading the CSS for a specific part of the template. The CSS file I am using is named styles.module.css: .my-page__title { font-weight: 300; font-size: 48px; margin-bottom: 15px; } .my-page_ ...

When I start scrolling down, the Jumptron background image vanishes

Utilizing bootstrap jumptron with a background image has led to an issue where the background image disappears as I scroll down, leaving only the jumptron div class displaying the heading. How can this be fixed so that the image remains visible even when s ...

Implementing Authorization Headers in Angular for Secure HTTP Post Requests

I have been struggling to add Authorization Headers to a Post request after extensive research and trying various ways of adding headers to the request. I need to authenticate the post request of my Angular app to a Django server. headers2 = { "Conte ...

The CSS ID selector fails to load on Android WebView

I am facing an issue while trying to load HTML with CSS that includes an ID selector. The file is not loading to the webview as expected. Here is the code snippet I attempted to load: <!DOCTYPE html> <html> <head> ...

Troubleshooting the Alignment Issue in Angular Material Expansion Panel Header

I have implemented an Angular 14 Material Expansion Panel as shown in the code snippet below... <mat-nav-list> <a mat-list-item role="listitem" class="list-item-setting" id="emailTemplatesId" matTooltipPosition=&quo ...

WebSocket Binary in Chrome version 16

I'm encountering issues while setting up a WebSocket server in node.js. After seeking help on stackoverflow, I managed to find a piece of code to use for the server. Here is the current server code: var net = require("net"), crypto = require("crypto" ...

What is the best way to transfer values from an iterated object in HTML to a component in Angular 2/4?

My Angular2/4 app allows for file uploads to S3. The setup is such that when a user uploads a file, it will be stored in an S3 bucket. Once uploaded, the user will be shown the list of files they have uploaded. In case they upload the wrong file by mistake ...

Pass the ID to a PHP script to retrieve the image source tag from the database based on the file

I am facing a challenge that I thought would be simple, but despite my efforts to research and experiment, I can't seem to get it right. I have a database that stores image file names, and I need to retrieve the file name based on the ID specified in ...

AngularJS: Error encountered when trying to assign a value to a read-only property in the ng-submit directive

I've been working on a personal project to practice angularJS, but I've encountered a problem that seems unsolvable to me. The issue arises when I try to utilize the submitLogin() function in my LoginCtrl.js file upon form submission. An error m ...

Tips for centering text within a description list using CSS

I need to figure out how to align the spans of the dt and dd elements horizontally in an HTML description list that includes an icon inside the dt element. <dl> <div> <dt><span class="ic"></span><span ...

Avoid Scrolling within an iFrame in HTML with the Use of #

I have a menu loading in an iframe with links using # like http://<location>/page.html#part1. When I click inside the iframe, the entire page outside of the iframe scrolls to the location of #. How can I stop this from happening? I only want the me ...

What is the process of adding CSS effects to a button when a keypress activates it?

Do you have a CSS style that transforms the look of a button when clicked on-page? Want to extend this effect to when the button is activated via keyboard? (In essence, browsers allow activating a button by pressing Tab to give it focus and then hitting S ...

The hover effect for a :before class is not functioning as intended

I have created a dropdown menu with a triangle at the top in this style: When the cursor hovers over only the triangle, it appears like this: However, when the cursor is over the div, the hover effect for both elements is activated as shown here: I am t ...

Ways to eliminate models that are not currently connected to the DOM

Within my form, I have implemented logic using ng-if to determine which elements are displayed based on user selections. For instance, if a user selects USA as the country, the state drop down will be shown as it was conditioned upon an ng-if for the count ...