Scrollable div containing content that triggers the appearance of a page scrollbar in Internet Explorer

Looking to enhance my company's internal data table component with sticky headers, I found a solution that works well in Chrome without disrupting other features. Here is the generated code:

<table class="headers">
    <thead> // ... header stuff</thead>
    <tbody> // ... body stuff</tbody>
</table>
<div class="scrollBody">
    <table class="headers">
        <thead> // ... header stuff</thead>
        <tbody> // ... body stuff</tbody>
    </table>
</table>

The corresponding CSS code looks like this:

th {
    border: 1px solid black;
}
.headers tbody {
    visibility: collapse;
}
.scrollBody thead {
    visibility: collapse;
}
.scrollBody {
    display: inline-block;
    max-height: 250px;
    overflow: auto;
}

While this setup works perfectly in Chrome, IE presents an issue by adding an extra scrollbar to the page. This results in two scrollbars, one for the table body and another for the entire page.

If you'd like to see the code in action, check out this CodePen link: https://codepen.io/petetalksweb2/pen/WyeaWL?editors=1100

Any assistance on resolving this issue would be greatly appreciated.

Answer №1

Enclose it within a div having the style property of overflow: hidden;

CodePen Example

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

Adding text to a hyperlink when hovering over it

I have searched extensively to find a solution for this issue, but I simply want to include a greater-than sign in my link when it is hovered over. I prefer not to use images or tables and so on. As someone more focused on backend development, I grasp the ...

Loading multiple Meteor templates is a breeze with the ability to hide data

I have implemented a selection box where users can choose which inputs are relevant to them. The goal is to dynamically load only the input fields that the user has selected, hiding those that are irrelevant. However, I feel that my current approach is clu ...

Unable to iterate through success response of AJAX call using a for loop

Upon receiving a JSON array in an AJAX call, I aim to dynamically display its elements in HTML. Rather than showing the entire array all at once, I wish to iterate through it and exhibit each element separately. Refer to the following code snippet for deta ...

Show or hide table columns easily without relying on jQuery

Within my HTML table that contains multiple columns, I aim to create a toggle feature for one specific column (in this case, the 4th column). Currently, I have accomplished this using jQuery: document.write('<a class="toggle" href="#!" data-alt="H ...

Can JavaScript be used to change the style and make a hidden input field vanish from view?

Currently, I am designing a table containing dates along with numerous hidden fields. print "<td"; { $dm=date('Y-m-d',strtotime("+".$i." days", strtotime($m))); print " class=\"overflow\" id=\"$a::$dm\" onclick=\" ...

Resize a responsive grid of images

Within my slider, I have three slides with 3 images each. The layout consists of one large image on the left and two smaller ones on the right. To ensure responsiveness, I've used max-width: 100% on the images so they can scale down proportionally as ...

Top ways to avoid default on anchor tags: best practices for preventing this issue

Previously, excluding the criticism for not using unobtrusive JS, I typically employed anchors with inline onclick attributes for AJAX loading in the following format: <a href="http://example.com/some/specific/link.php?hello=mum" class="menu" id="m ...

Transforming the Looping Data in the GetJson Array into a Clickable Link

I am facing an issue with creating a list of markers on my Google Maps. I want to make a link that will display the values of each marker on the list, as it is looped through using getJson and <li> is only appended during the loop. Could someone ass ...

Tips on creating a clickable div container

Is it possible to add a hyperlink to an entire div element along with its background color and other styles? The goal is for the hyperlink to execute whatever is attached to the id when the selected div is clicked: <div class="className" style= ...

Mystery of the Unresponsive MD Ripple Button

While working on creating a CSS button, I wanted to incorporate the Material Design ripple or wave effect into it. I came across a simple script on codepen that works well by adding the class "ripple" to various elements such as divs, buttons, images, and ...

Filtering HTML tables to display only one instance of each value

I have a 300x11(rowXcolumn) html table that I wanted to filter like Excel or Google Sheets's filter. Upon researching, I came across the code below on a website. While it works as desired, there is an issue where it displays the same value multiple ti ...

Certain Android devices may experience compatibility issues with the web app

I am facing an issue with my webapp on Raspberry Pi, as it is not being recognized properly by all my Android devices. The server hosting the website is a Raspberry Pi 3 running Apache and everything is up to date. To protect privacy and security, all IP ...

Trouble with aligning action buttons in rows or columns with CSS

I am working with an HTML table that has dynamically created rows and columns using AngularJS. I want to add an option where users can hover over a row or column and see a delete button icon that, when clicked, will remove that row or column. While this fu ...

Is it possible to completely change the displayed text using the :hover effect?

I have been unable to find any other platform where I can seek advice on this particular issue. I am currently working on editing the CSS of a website for a friend who wants the title text to change when hovered over. However, despite my efforts, I have st ...

Checking the Value of the Second Child Element Using jQuery

I am struggling with a DIV structure that looks like this: <div class="metafield_table"> <div class="metafield"></div> <div class="metafield"></div> <div class="metafield"> ...

Is there a way to remove background-color for a:focus?

When working with Twitter Bootstrap, I encountered a challenge. The background-color properties set for navigation items on the :focus state were causing an issue for a specific navigation element that needed have its own styling. Imagine a scenario where ...

A duo of adjacent buttons styled with HTML, CSS, and Bootstrap

I'm encountering an issue with the layout of my design. On my product page, I have two buttons placed on top of each other because one is within a form (refer to the image). https://i.sstatic.net/cS9TI.jpg I would like to position the two buttons s ...

Issue: Unspecified Index encountered when making an Ajax call

I'm encountering an issue where I am receiving an "Undefined Index" error while trying to call Ajax. My goal is to post JSON data to the "update.php" page when the submit button is clicked. Essentially, I want to gather the values in textboxes and sen ...

Acquiring HTML form information in ASP.NET controller

Currently, I have a view that includes an HTML login form and I am working on passing the form values to a controller via post. My goal is to display the user's username using the Content method once the form is submitted. However, I am facing an issu ...

Height of dropdown items in the horizontal navbar

I am working on a navbar that includes a dropdown menu. Currently, the dropdown items are being displayed horizontally in full width with a larger height. However, I would like them to be displayed vertically in full width and with a smaller, normal height ...