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

swap between style sheets glitching

My website features two stylesheets, one for day mode and one for night mode. There is an image on the site that triggers a function with an onclick event to switch between the two stylesheets. However, when new visitors click the button for the first ti ...

Styling Material UI components with CSS is a great way to

I'm facing difficulties while working with Material UI components. Currently, I have a Material UI table and I want to center-align the text within it. The standard CSS of Material UI contains an element named MuiTableCell-root-60 which has a text-a ...

Tips for choosing an option from a react dropdown using Cypress

Exploring Cypress: I am currently working with the following code snippet. Although it seems to be functioning, I have a feeling that there might be a more efficient way to achieve the desired result. There are 25 similar dropdowns like this one on the pag ...

Large button in Bootstrap 3 breaks out of Jumbotron on smaller mobile screens

I have set up my layout with a Jumbotron that features a prominent call-to-action button. <a href="#" class="btn btn-lg btn-success">Let's Purchase Something Elegant</a> However, when viewed on an XS mobile screen, the button extends bey ...

Certain HTML elements on the webpage are not functioning properly when attempting to incorporate a div tag

One of the challenges I'm currently facing is that the links for HOME and ABOUT ME in the header section are not accessible when the 'data' div is added. Strangely, the DOWNLOAD and CONTACT ME links still work fine. This issue seems to be oc ...

Facing a minor HTML syntax error while attempting to configure metatags in Ruby on Rails

I'm attempting to incorporate social tags into my site, such as Tweet count, Facebook recommendations, and their respective numbers. In the app/views/application/_ogmeta.html.erb file, I have only included one line: <meta property="og:title" cont ...

Adjustable DIV based on screen size

I am attempting to create a flexible div that will adjust its width and height proportionally based on the viewport size. However, in the example above, this method only seems to make the div expand horizontally without affecting the vertical height (wh ...

I am facing difficulties accessing an element within a controller in Angular

Struggling to access an element inside an AngularJS controller, I attempted the following: var imageInput = document.getElementById("myImage"); Unfortunately, this approach was unsuccessful as the element returned null. Curiously, when placing the statem ...

The Bootstrap Navbar appears hidden beneath other elements on mobile devices

While using bootstrap to style my header contents, I encountered a strange issue. The navbar that appears after clicking on the hamburger menu is displaying behind all the components. Even though I've set the z-index to the maximum value, it still doe ...

Develop an outline using D3.js for the clipath shape

After successfully creating a shape with a color gradient, I encountered the need for further customization. If you are interested in this topic, check out these related questions: Add multi color gradient for different points in d3.js d3.js scatter plot c ...

Guide on automatically populating login data in an html5 form using a python script

I'm currently attempting to create a script that can automatically populate the values of an HTML5 form (specifically Name and Password fields). However, I am struggling with how to actually input these values. After searching various sites, I have y ...

My React application is not showing the CSS styles as intended

In my project, I have a component file named xyx.js where I properly imported my scss file './xyz.scss'. Both of these files are in the same folder. Interestingly, when I view the styles using the Chrome scss extension, everything seems to be wor ...

Troubleshooting Alignment Problem of Maximize and Close Icons in RadWindow Using ASP.Net

Currently, I am utilizing telerik radwindow to showcase a PDF document. The window seems to be functioning correctly, but there is an issue with the alignment of the maximize and close icons. Ideally, they should appear in the same row, however, they are b ...

Divs Stacked and Centered

I am currently utilizing the card components from Google's Material Design Lite HTML theme, which can be found at . At the moment, my cards are positioned next to each other and aligned to the left side of the page. I am looking to center the cards o ...

variances in CSS performance between local and remote hosting

My team and I are all using Internet Explorer 8 on Windows 7 Professional, with Visual Studio 2010 Premium. However, we have noticed that when running our application in localhost mode versus remote mode (on the server), there are differences in the CSS re ...

I'm having trouble getting the npm install for classnames to work within my li tag

I need some help with React JS. I'm attempting to merge my classes using the npm package called classnames. https://www.npmjs.com/package/classnames However, I'm encountering an issue: classnames doesn't seem to be working as expecte ...

Encountering a problem with the divLogoBlock element in the code snippet below

I am experiencing an issue with the code below. The divLogoBlock does not appear when I copy and paste the entire page into Outlook as a signature. I believe there may be a problem with the CSS. Can someone please assist me? <html lang="en"><he ...

Is there a way to generate PDF files from rrdcgi output?

I have developed an rrdcgi script to showcase system performance data through graphs. I am now seeking a way to allow users to generate PDFs on the spot, containing the current page's images and information along with header and footer details. Additi ...

Incorporating Anchors for Seamless Navigation in Menus

My website has various sections on the homepage and I want to add an anchor link to the navigation. This will allow users to scroll down to a specific section, like "About Us," when clicking on the appropriate nav link. I also need the anchor link to work ...

Guide on modifying HTML attribute with TFHpple in the Swift programming language

I have received an HTML string and I want to modify the elements inside them, specifically the img tags, so that they have a style of width = 100% and height set to auto. This way, when I embed these images into a web view, they can easily adjust to fit th ...