Implementing a tooltip popup inside the header cell of the ordering table

Apologies in advance for my lack of experience with coding more complex website features.

I'm attempting to incorporate a tooltip popup into one of the header cells to provide additional information to users.

While I have all the necessary components, I am struggling to seamlessly integrate the existing table code with the tooltip function.

HTML:

<div>
 <table id="lst-table">
  <thead>
    <tr>
     <th class="lst-th" scope="col">Model <br>Ref.</th>
     <th class="lst-th" scope="col">Perf <br>Type</th>
     <th class="lst-th" scope="col">LST Cover <br>Length</th>
     <th class="lst-th" scope="col">LST Cover <br>Colour</th>
     <th class="lst-th" scope="col">Mounting <br>Type</th>
     <th class="lst-th" scope="col">TRV <br>Aperature</th>
     <th class="lst-th" scope="col">Healthcare</th>
     <th class="lst-th" scope="col">Sloped <br>Top</th>
     <th class="lst-th" scope="col">Quantity</th>
     <th class="lst-th" scope="col">Order <br>Code</th>
    </tr>
  </thead>
 </table>
</div>  




<br><br><div class="tooltip-lst">ⓘ
  <span class="tooltiptext">Is an aperature required to accommodate a   Thermostatic Radiator Valve (TRV). TRV supplied by others.</span></div>

CSS (tool tip css code is final three paragraphs):

.lst-table{
text-align: right;
position: relative;
border-collapse: collapse;
background-color: #7F7753;
}
.lst-td, th {
border: 1px solid #999;
padding: 10px;
}
.lst-th {
background: #7F7753;
color: white;
border-radius: 0;
position: sticky;
top: 0;
padding: 10px;
}
.lst-input-ral-box {
border: 1px solid #d7d6d6;
display: flex;
gap: 0;
width:85px;
}
.lst-input-ral-box:focus-within {
border: 0px solid #000;
}
input {
border: none;
outline: none;
}
.tooltip-lst {
position: relative;
display: inline-block;
}
.tooltip-lst .tooltiptext {
    visibility: hidden;
    width: 120px;
    background-color: black;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px 0;
  
    /* Position the tooltip */
    position: absolute;
    z-index: 1;
}
  
.tooltip-lst:hover .tooltiptext {
    visibility: visible;
}

Any assistance with this issue would be highly appreciated.

Answer №1

To ensure the popup displays properly, it should be placed within the relevant th element (particularly the one labeled TRV).

Additionally, it's important to make sure that the popup appears in front of neighboring th elements when shown, preventing any coverage issues.

The snippet below adjusts the z-index of the th element while hovering to achieve this effect:

<style>
  .lst-table {
    text-align: right;
    position: relative;
    border-collapse: collapse;
    background-color: #7F7753;
  }
  
  .lst-td,
  th {
    border: 1px solid #999;
    padding: 10px;
  }
  
  .lst-th {
    background: #7F7753;
    color: white;
    border-radius: 0;
    position: sticky;
    top: 0;
    padding: 10px;
  }
  
  .lst-input-ral-box {
    border: 1px solid #d7d6d6;
    display: flex;
    gap: 0;
    width: 85px;
  }
  
  .lst-input-ral-box:focus-within {
    border: 0px solid #000;
  }
  
  input {
    border: none;
    outline: none;
  }
  
  .tooltip-lst {
    position: relative;
    display: inline-block;
  }
  
  .tooltip-lst .tooltiptext {
    visibility: hidden;
    width: 120px;
    background-color: black;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px 0;
    /* Position the tooltip */
    position: absolute;
    z-index: 1;
  }
  
  .lst-th:hover {
    z-index: 2;
  }
  
  .tooltip-lst:hover .tooltiptext {
    visibility: visible;
  }
</style>
<div>
  <table id="lst-table">
    <thead>
      <tr>
        <th class="lst-th" scope="col">Model <br>Ref.</th>
        <th class="lst-th" scope="col">Perf <br>Type</th>
        <th class="lst-th" scope="col">LST Cover <br>Length</th>
        <th class="lst-th" scope="col">LST Cover <br>Colour</th>
        <th class="lst-th" scope="col">Mounting <br>Type</th>
        <th class="lst-th" scope="col">TRV <br>Aperature
          <br><br>
          <div class="tooltip-lst">ⓘ
            <span class="tooltiptext">Is an aperature required to accommodate a   Thermostatic Radiator Valve (TRV). TRV supplied by others.</span>
           </div>
        </th>
        <th class="lst-th" scope="col">Healthcare</th>
        <th class="lst-th" scope="col">Sloped <br>Top</th>
        <th class="lst-th" scope="col">Quantity</th>
        <th class="lst-th" scope="col">Order <br>Code</th>
      </tr>
    </thead>
  </table>
</div>

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

Incorporate a Fadein effect into the current CSS for mouseover link interaction

Is there a way to enhance my current css code for a mouseover link with a background image by adding a fade in and out effect? What's the most effective method to achieve this using jquery? .sendB { width: 100%; height: 125px; background: ...

Bootstrap5: Left-aligned Navigation Bar Pills and Right-aligned Text

I am trying to align all my navigation pills to the left, and then add a single text element that stays at the end of the navbar even when the page is resized. Navbar Image My attempt involved adding a div so that the navbar pills would take up 50% width ...

The background extends beyond the confines of its container

I'm facing some challenges trying to create this specific layout, particularly with setting a background that should cover 50% of the screen size. My initial thought was to use an image as the background, but I need different colors for each page. ht ...

Enhance the "text" attribute of IXMLDOMElement to enable functionality in Chrome

The web application I am currently working on was developed approximately 10 years ago and is only compatible with Internet Explorer. My goal is to make it functional in Chrome as well. I am facing a challenge regarding the "text" property of IXMLDOMEleme ...

Plugin for turning text into "leet speak" using jQuery and Javascript

Recently, I've been on the hunt for a 1337 translator that I can seamlessly integrate into a jQuery plugin. While I believe I'm making progress, I can't shake off the feeling that something's amiss. My gut tells me that what I currently ...

When an if statement is triggered by an overload of information, it initiates the start of a fresh

I am in need of creating an if statement that will trigger whenever images with IDs 0 to 3 (a total of 4 images) are loaded. This if statement should then generate a new row containing 0 to 3 images, and the same logic needs to be applied for words as well ...

Steps to prevent cart resizing in desktop view:

For a front-end challenge, I need you to design a simple card that displays consistently in both mobile and desktop views. I took a mobile-first approach because I've encountered issues where the card layout changes when viewed on desktop. Check out ...

Unlock the power of Component level CSS in NextJS with this simple guide!

I don't have much experience with CSS, as I rarely write it these days due to the popularity of libraries like MUI. However, I recently found myself in a tricky situation where I needed to rewrite this example Emabla carousel in typescript and NextJS. ...

Utilize Bootstrap's collapsible navbar feature to smoothly navigate to a designated section of the webpage

After creating a navigation bar using bootstrap 4, I encountered an issue when trying to collapse the navbar and jump to an anchor simultaneously in mobile view. If I only include href="#services", it successfully jumps to the correct section of ...

Issues with the aligning of buttons using the justify-content property

The issue I'm facing involves a parent container with 3 buttons nested inside. The parent container is set to display:inline-flex, however, the justify-content: space-between property is not behaving as expected. Each button has a defined max-width in ...

Unusual Happenings with jQuery Draggable

Currently, I am experimenting with jQuery draggable to move individual letters of the word "Hello" around on the page. However, I have come across a frustrating issue. When I drag the letter H towards the right and it gets near the letters E, L, L, or O, ...

Injecting HTML with jQuery and AJAX and Implementing Gallery Plugins

In my exploration of jQuery and loading HTML from external files, I've encountered a problem. My goal is to extract a URL parameter, use it to load a file named data.html where the data represents the parameter value for gallery, inject the content of ...

Is the side tab overflowing the window due to its absolute positioning?

My browser window has a side tab that slides in when clicked using jQuery. The issue I'm facing is that the tab overflows the body due to its absolute positioning. However, the overflow stops when the tab is pulled in by jQuery. It only happens when t ...

Inquiring about browserify or webpack on a website using node - a few queries to consider

Seeking assistance with a website project I am currently working on. The project consists of 7 HTML documents, 3 stylesheets, 8 JavaScript files (including jQuery.min.js and some additional jQuery plugins), and various images. I am looking to bundle and mi ...

Modify the alignment and orientation of the data within RadHtmlChart

I have a chart: <telerik:RadHtmlChart ID="chrtInvestmentAmount" runat="server" Transitions="true" DataSourceID="SqlDataSource1" Height="256px" Skin="Glow" Width="1024px" RenderMode="Auto"> <PlotArea> <Series> ...

The process of how screen readers interpret HTML elements

It is important to understand that screen readers not only read the content within elements and tags, but also the elements or tags themselves. For example: <button class="class-of-the-button">Text inside</button> When read by a screen reader ...

The mysterious workings of the parseInt() function

As I begin my journey to self-teach JavaScript using HeadFirst JavaScript, I've encountered a minor obstacle. The chapter I'm currently studying delves into handling data input in forms. The issue arises when I attempt to utilize the updateOrder( ...

Add some TD(s) after the td element

The HTML code I currently have is as follows: <tr> <td class="success" rowspan="1">Viability</td> <td data-rowh="-Checksum">Viability-Checksum</td> </tr> <tr> ...

Searching and manipulating arrays in PHP

<?php include 'database.php'; $sql="SELECT `j_company`,`j_salary`,`j_title` FROM `jobs`"; $query=mysqli_query($conn, $sql); if(!$query) { echo "<h1>Unsuccessful</h1>"; echo("Error description: " . ...

Switching colors on SVG when hovering

When I hover over the code below, I want both eyes and eyebrows to change color. I've managed to get it working for the left eye, but not the right eye. Additionally, the fill on the right eyebrow looks strange when hovered over. I suspect this issue ...