Cursor-hugging tooltip

My tooltip creation works when hovering over an icon, but there's a slight issue - it doesn't always follow the cursor and can get stuck at times.

To see a demo of this in action, click here: fiddle

Here's the code I'm using:

HTML

<a href="#" class="tooltip"><img src="http://i.imgur.com/JkhlPKF.png"><span>Equipment</span></a>
<a href="#" class="tooltip"><img src="http://i.imgur.com/lgHQamk.png"><span>Maps</span></a>

CSS

.tooltip {
    text-decoration:none;
    color: black;
    position: relative;
}
.tooltip:hover {
    text-decoration: none;
    cursor: default;
}
.tooltip span {
    display: none;
}
.tooltip:hover span {
    display: block;
    position: absolute;
    width: 80px;
    z-index: 100;
    background: #FFFFCC;
    text-align: center;
    border: 1px solid black;
    text-decoration: none;
}

If CSS can't handle fixing the cursor issue, would simple JavaScript (without jQuery) be a viable solution?

Appreciate any guidance on this matter. Thank you.

Answer №1

When working with just CSS, it can be quite challenging to come up with a solution. However, here's a trick you might find useful: Wrap a span element around the description tag and set it to display as a block with relative position and a z-index of minus one (one less than the description's z-index). Then, add a rule so that when hovering over the wrapper, the description is displayed as a block.

<a href="#" class="tooltip"><img src="http://i.imgur.com/JkhlPKF.png"><span class="wrapper"><span class="describe">Equipment</span></span></a>

I've created an example based on your suggestion: http://jsfiddle.net/T2YxQ/

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

Regular expression: Search for a particular word following the initial appearance of a backslash

I need help with creating a regex pattern to find the word "bacon" after the first "/" in a URL. Here are some examples: Expected to return true: console.log('1 - ', myRegexFunction('www.bacondelivery.com/weekly-bacon-delivery/')); co ...

Creating an HTML form that triggers a PHP script to send email upon submission via a Google Cloud Server

While running a php script to send an email upon form submission, I encountered an error message. Here are the details of the error: This XML file does not appear to have any style information associated with it. The document tree is shown below. &l ...

What could be causing the header of the datatable to be out of alignment with the rest of

I'm facing an issue with my datatable where the header is misaligned with the content. Can someone please assist me in adjusting the header and content so that they are parallel? It doesn't look right at the moment. <div style="margin-top:1 ...

What could be causing this template to malfunction?

Every time I try to start my Express server and access the page, I encounter an error. Can anyone pinpoint what might be wrong with the syntax? The "startzeit" property is a Date() Object. <tbody> <% for (let seminar in seminare){ %> ...

Is there a way to store a class property as a variable using PostCSS?

Looking to store a dynamic property in a variable for use with calc(). There is a class with a height that changes dynamically. .cuerpo-detalle { height: x; } The goal is to create a variable that captures the height property of the .cuerpodetalle cla ...

Can you tell me the alternative for window.location.href when using Vue router?

After performing an action in my Vue app, I am looking to redirect to a different page within my single-page application (SPA). However, when I use the code window.location.href = "/subpage", the page refreshes and I end up losing cached data tha ...

Can you provide me with the accurate URL to access my Web API endpoint in asp.net?

I'm currently utilizing an API in my asp.net project and attempting to access it from my JavaScript file. However, I suspect there may be an issue with the URL I am using. Here is the controller and method I am trying to retrieve: [Route("api/[co ...

SVG Star Rating system designed to accommodate ratings with decimal points

I am struggling with creating a star rating using SVG for the first time. I need the rating to be out of 5 and display decimal ratings like 4.5, 3.2, 1.1 along with whole stars. The rated stars should be yellow while the remaining stars should be grey. How ...

jQuery not functioning properly when attempting to add values from two input boxes within multiple input fields

I am facing an issue with a form on my website that contains input fields as shown below. I am trying to add two input boxes to calculate the values of the third input box, but it is only working correctly for the first set and not for the rest. How can ...

Show dynamic outcomes on the site

I'm currently in the process of building a website for a travel search engine and I'm interested in displaying the results in a similar manner to what is done on Hipmunk. https://i.sstatic.net/JWvYo.png Here are some key details: The website ...

Showing text in a textarea while maintaining formatting (such as using <br>)

Can someone help me with formatting a block of text like this: hello <br> how is your day <br> 123 To look like this: hello how is your day 123 I also need to display it in a textarea field. I attempted to do so using the following code: $ ...

The jQuery.ajax converter function is not being triggered

I'm struggling with jQuery.ajax converters - my converter function isn't triggering. This is the simplified jQuery AJAX code I'm using: $.ajax({ url: "http://myurl/myservice", dataType: "JSONP", cache: false, success: ...

Using logic to eliminate elements

During the concluding ceremony, I have a plan in mind: In case there is only one input field: Do nothing If multiple input fields exist and none of them are empty: Do nothing For multiple input fields where at least one field has content: Remove all ...

Is it possible to achieve a Column Chart output in R/Highcharts?

Looking to utilize highchart to create a chart with columns stacked within each other for different countries. https://i.sstatic.net/2p1uM.png I want the smaller column to be nested inside the larger one for each country. Any suggestions on how I can ac ...

Adjust the color of the chosen <li> item to a different shade

I want to change the text color of the "Sale" item, but not a phone number using only CSS. Unfortunately, I am unable to modify the HTML code. https://i.stack.imgur.com/PPnna.png .menu.left a:first-child { background: yellow; color: red; } https ...

What is a straightforward method to display one Div while concealing all others?

Is there a simpler method to display one div and hide all others, with the first one shown by default? My current solution using jQuery works, but it feels lengthy. I believe there might be a more efficient way to achieve this. Here is the code snippet: ...

Implementing NodeJS to showcase an array of items - the step-by-step guide

I'm currently setting up a webpage to display a list of books using NodeJS, but despite my efforts, the page remains blank when I launch it. My goal is to showcase the array of books on the page, and so far, here's the code that I have written. A ...

What is the best way to conceal specific series in a HighCharts legend?

In the chart, I currently have 4 series. At the moment, only 2 of them are visible while the other 2 are hidden when the chart first loads. As the user zooms in on the chart, the visibility of the series changes dynamically. I need help figuring out how ...

Adding Borders to a Single Column in Bootstrap

Is it possible to add borders in the color 'info' to the last column in a table? I'm struggling with this. Can anyone provide assistance? Does Bootstrap have the capability to support this design element? This is what I have tried so far: ...

There seems to be an issue with the functionality of Angular Material in Angular9

I've encountered an issue with the material form field, even after importing the necessary modules. Surprisingly, there are no console errors to provide more insight into the problem. { "name": "online-shop", "version": "0.0.0", "scripts": ...