Seeking guidance on creating an uncomplicated CSS tooltip

Can anyone help me troubleshoot why my CSS tooltip isn't working correctly? I've been trying to create a simple method for tooltips, but they are displaying inconsistently across different browsers. In Firefox, the tooltips appear in random locations, and in IE, only the first tooltip is functioning properly.

Any assistance would be greatly appreciated. Thank you!

</html>
    </head>
        <title> Sample CSS Tooltip Test </title>
        <style type="text/css">
            body {padding: 0px; margin: 0px; font: 80%; font-family: sans-serif;}

            div.container {padding: 10px 10px 10px 25px; }

            thead {background-color: #00f; color: #fff;}

            th { text-align: center; padding: 4px 6px 4px 6px; }

            td { text-align: center; padding: 4px 6px 4px 6px; }

            a:link {text-decoration: none;}
            a:hover {text-decoration: none;}
            a:visited {text-decoration: none;}

            a.myLink {position: relative; z-index: 24;}
            a.myLink:hover {z-index: 25;}
            a.myLink span.tooltip {display: none;}
            a.myLink:hover span.tooltip {display: block; position: absolute; overflow: visible; top: 0em; left: 8em; width: 20em; color: #fff; background-color: #000; border: solid 1px #c6d880; padding: 2px 4px 2px 4px; font-family: serif; font-size: 1em; font-weight: 700; text-align: left; z-index: 100;}

            td.myCell {position: relative; z-index: 24;}
            td.myCell:hover {z-index: 25;}
            td.myCell span.tooltip {display: none;}
            td.myCell:hover span.tooltip {display: block; position: absolute; overflow: visible; top: 0em; left: 8em; width: 20em; color: #fff; background-color: #000; border: solid 1px #c6d880; padding: 2px 4px 2px 4px; font-family: serif; font-size: 1em; font-weight: 700; text-align: left; z-index: 100;}

            button.myButton {position: relative; z-index: 24;}
            button.myButton:hover {z-index: 25;}
            button.myButton span.tooltip {display: none;}
            button.myButton:hover span.tooltip {display: block; position: absolute; overflow: visible; top: 0em; left: 8em; width: 20em; color: #fff; background-color: #000; border: solid 1px #c6d880; padding: 2px 4px 2px 4px; font-family: serif; font-size: 1em; font-weight: 700; text-align: left; z-index: 100;}
        </style>
    </head>
    <body>
        <div class="container">
            <table border="1">
                <thead>
                    <tr><th> Sample Table with CSS Tooltips </th></tr>
                </thead>
                <tbody>
                    <tr><td><a class="myLink" href="http://www.google.com/" target="_blank"><span class="tooltip">this is a tooltip for cell 1</span>Visit Google</a></td></tr>
                    <tr><td class="myCell"><span class="tooltip">this is a tooltip for cell 2</span>Second Cell</td></tr>
                    <tr><td><button class="myButton" type="submit"><span class="tooltip">this is a tooltip for cell 3</span>Clickable Button</button></td></tr>
                </tbody>
            </table>
        </div>
    </body>
</html>

Answer №1

If you want to simplify something and add animation, you can try the following code:

<html>
<head>
    <style>
        .animate {
            -moz-transition: all 0.3s ease-out;  /*FF3.7+*/
            -o-transition: all 0.3s ease-out;  /*Opera 10.5*/
            -webkit-transition: all 0.3s ease-out;  /*Saf3.2+, Chrome*/
            transition: all 0.3s ease-out;
        }
        /* Button */
        .button{position:relative;width:120px;height:100px;margin-top:60px;}

        /* Initial Tooltip state */
        .tooltip{position:absolute;opacity:0;top:0px;right:0px;background-color:black;color:white;padding:4px;}

        /* Hover Action */
        .button:hover .tooltip{opacity:0.9;top:-50px;right:0px;}
    </style>
    </head>
<body>
<div class="button">Here is a portion of your text
    <div class="tooltip animate">And this is where the tooltip content goes.</div>
</div>
</body>
</html>

Feel free to give it a test run!

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

Issues with Curved Corner Touchdown Feature

Having trouble with getting the round css to work properly in the below code It seems to be only applying the background color, but not the border styling The border code is on the same line as the round css: style=" border : 1px solid #D6D6D6; and t ...

Tips for applying personalized CSS to individual Toast notifications in Angular

MY QUESTION : I am looking to customize the CSS of a single toast used in Angular components. While there may be multiple toasts, I specifically want to style one particular toast differently. For example, the toast image can be viewed here: example toast ...

The initial child expands in width according to the content until it reaches the boundaries of the parent, triggering the

My goal is to achieve a layout where the parent container's width can vary. The first child element (red) should expand based on its content until it reaches the end of the parent, at which point text-overflow: ellipses should be applied. The second c ...

Page designed for displaying small star ratings in JSP

In the realm of my star.jsp page, the style.css is its trusty companion, faithfully executing its duties. However, a desire has crept into my heart - I yearn for the stars to shrink in size. The Chronicles of My Code star.jsp <!DOCTYPE html> ...

How can I ensure that a button remains fixed at the bottom of a Material UI React Component?

I am currently working on developing a layout for a web application, and I have encountered an issue that I am struggling to resolve. The structure of my grid is as follows: My goal is to ensure that each section inside the card starts at the same point. ...

Is there a concept of negative margin "wrapping"?

I am currently working on the website . I am facing an issue where the left arrow is not appearing in the same position as the right arrow. When I try to mirror the same adjustment I made for the left arrow by using margin-left: -75px, it seems to 'wr ...

Creating a dynamic CSS animation with multiple spans for typing effect

I have made some progress with this project. Here is the link to what I have so far: http://codepen.io/tacrossman/pen/GJglH However, my goal is to have the cursor blinking animation running after each new word (span) is written out. When I attempt to ad ...

Enhancing Drag and Drop Functionality with jQuery and CSS Zoom Effect

I am facing an issue in my application with a div that has variable CSS zoom. Due to this, the coordinate space gets disrupted. The page pixel is no longer equal to 1px when hovering over the zoomable area :) This breakdown in the coordinate system is ca ...

Tips on effortlessly updating the URL of your website

Despite seeing the question asked multiple times, I still find myself struggling to understand how to modify a URL or create a new HTML page that seamlessly integrates into a website without redirecting users. I am curious about achieving the functionalit ...

I'm having trouble getting the second controller to function properly in my AngularJS application

I've been looking everywhere for a solution on how to implement two controllers, but I can't seem to get it working. Could there be something wrong with my HTML or could the issue lie in my script? Here is the JavaScript code: <script> v ...

The dimensions of the pop-up window in Chrome's JavaScript are not displaying correctly

My goal is to launch a new chat room window on our website. The dimensions of the chat room are set to 750px x 590px. Below is the link I am using to trigger the javascript popup. <a href="javascript:void(0)" onclick="window.open('http://gamersuni ...

I am unable to determine if I have already selected a List Item

My goal is to have a functionality where clicking on "Download Drivers" will open the list, and clicking again will close it. This should be achieved with onclick events only, no hover effects. Additionally, I want the list to remain open even if I click o ...

Utilizing a StyledComponents theme within a Component

When creating a style called Link, the theme is contained inside of this.props. How can the theme be extracted from props and passed into the Link styled component? Error: ReferenceError - theme is not defined import React from 'react'; impo ...

What is the most effective method for implementing a background repeated image in Foundation 4 framework?

Currently, I am utilizing the foundation4 framework for my website. In order to achieve a repeating tiled background, I have crafted a custom CSS file and included the following code snippet: body { background: url(img/floorboardsbg.jpg) repeat; } Whi ...

How to center a label vertically within a button group using Bootstrap

How can I vertically align labels for 2 inline elements inside a horizontal form without using hacks like display:table? So far, this is the code I have tried: bootply ...

Tips for positioning a solitary md-tab component to the right

Can a single md-tab element be aligned to the right of md-tabs while keeping the rest of the tabs in their original position? ------------------------------------------------------------------------- | Tab 1 | Tab 2 | Tab 3 | ...

What is the best way to stack div elements one after the other?

I am a complete beginner in HTML and I have a project for my web design class about a movie. http://jsfiddle.net/Lbo1ftu9/ <div id="footer"> <a href="D:/MOVIE REPORT/akira.htm" title="GO BACK?"><img src="D:/IMAGES/goback.gif"> My code ...

Do arrays permanently retain the strings stored within them?

As an 11-year-old who has been learning Javascript for the past month and a half, I am currently working on creating a login/register system. Right now, my focus is on the register part. I have a question: when adding a string/number/boolean to an array, d ...

Use jQuery's animate function to toggle a different div when clicking on one

Having trouble with a jQuery function that keeps triggering the second function every time I click. How can I fix this issue? I designed a navbar with 3 links, each linked to a different .contentDiv with unique IDs. Whenever a link is clicked, a toggle fu ...

The attribute selector is malfunctioning

Currently, I am attempting to target img tags based on the alt attribute in order to correctly load a background-image on mobile devices. The issue I am encountering is that regardless of the combination of attribute selectors I use, it does not seem to w ...