The issue of non-sticky table headers persists in Microsoft Edge and Brave browsers

I have implemented a solution to make the table header sticky on scroll. The solution works perfectly in Chrome and Firefox, but I am facing issues with it in Edge and Brave Browser.

I've experimented with making the table header absolute, but this caused disruptions to the overall table structure. I'm struggling to find a way to ensure cross-browser compatibility.

For reference, here is the link to the code on jsfiddle: https://jsfiddle.net/zp1Lk6mw/

Below is the code snippet:

HTML

<div class="table-wrapper table-1">
                <div  id="table-1-container" class="table-container">
                    <table class="table">

                <thead id="table-1-head">
                    <tr class="table-header">
                        <th>Column 1</th>
                        <th>Column 2</th>
                        ...
                        
                        // Code truncated for brevity
                    </tr>
                </thead>
                
                ...

            </table>
                </div>
            </div>

CSS

:root {
    --orange: #f47a14;
    --blue-header: #003f5b;
    --dark-grey: #999999;
    --light-grey: #f8f8fc;
    --text-color: #333333;
}

// CSS rules omitted for space reasons
...

.table tr td div::-webkit-scrollbar {
    height: 0px;
}
.table tr td div::-webkit-scrollbar-thumb {
    border-top: 1px solid rgba(0, 0, 0, 0);
    background-clip: padding-box;
    border-radius: 9999px;
    background-color: var(--dark-grey);
}

Answer №1

Adhesion necessitates the use of position: relative, which is not suitable for thead or tr. However, it does work for th, so you can apply the following:

table th{
    position: sticky;
    top: 0;
}

By doing this, the table header will remain sticky.

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

looping through a datatable using a foreach loop

I am working on a project involving a data table and need to create a loop that will render an HTML table from scratch without using abstracted data sources. One of the requirements is to make the number of items per row flexible and adjustable as needed. ...

Using Selenium to capture text for later validation and storage in a variable

Using Selenium in Visual Studio. I require assistance with developing two test cases. UPDATED: Extract a serial number from one text field and save it in Variable A. Retrieve another serial number from a different text field and store it in Variable ...

Overlap between sidebar and navbar

I am currently working on developing an admin panel for one of my projects. I designed a sidebar and implemented a standard bootstrap 4 navbar. However, I encountered a minor issue where the bootstrap 4 navbar is extending to the full width of the page ins ...

Using a function on a singular element

I'm currently working on my portfolio and I would like to organize my projects in a menu similar to this felipestoker.com When you click on Works, it displays a menu with my projects categorized. However, when I click on a category, all of them appea ...

What is the best way to align elements within a row/column layout in Angular Material when working with divs?

To set up two div blocks in a row, I'm utilizing the code below: <div layout="column" layout-gt-xs="row" layout-align="center center" id="row"> <div id="a">a</div> <div id="b">b</div> </div> The CSS for this ...

Is there a way to expand my dialog box to fill the entire screen?

Currently, I am studying a tutorial on creating an angular lightbox, which can be found here. However, I am facing an issue where the lightbox only expands to the size of the div when I place the button inside it. The code snippet in question is as follows ...

Transition in CSS did not work as expected when the class of the sticky element was

My goal is to create a transition effect when an element becomes sticky on the page. However, I am facing issues with the current code that I have. const content = document.querySelector('.contents'); const initalPos = content.offsetTop; wi ...

Aligning a multi-line list element vertically to the bullet point

When my list breaks into multiple lines on certain screen sizes, I'm facing an issue where the list bullet doesn't align vertically in the middle of the text. I want the bullet to show up next to the second line if there are 3 lines inside the s ...

Firefox fails to render SVG animation

Currently, I'm attempting to incorporate this unique animation into my website: http://codepen.io/dbj/full/epXEyd I've implemented the following JavaScript code in order to achieve the desired effect: var tl = new TimelineLite; tl.staggerFromTo ...

center items alignment with hidden tags

I'm currently facing an issue with the CSS property display: flex, align-items: center Here is a snippet of my HTML and CSS files: * { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Kumbh Sans', sans-serif; } .na ...

Executing a Javascript function post AJAX page loading

I'm not a coding expert, so I hope my question is still clear. Essentially, I have an index.php page with filters (by project, year, month) that send variables to filterData.php after clicking submit. These variables are then used in SQL statements t ...

Are you looking for a helper class to generate HTML emails using .NET?

While developing my web forms website, I found myself relying heavily on the default MailMessage and SmtpClient classes to send HTML emails. However, my biggest issue is the abundance of hardcoded HTML used for email formatting. Are there any specific .N ...

Ways to make the Select component in Material-UI lose its focus state once an item has been selected

Anticipated outcome: Upon selecting an item, the Menu list will promptly close, and the Select component will no longer display a focus state. The borderBottom will change to 1px solid, and the backgroundColor will turn to white. Current situation: Sele ...

Utilizing either Maps or Objects in Typescript

I'm in the process of developing a simple Pizza Ordering App. The concept is, you select a pizza from a list and it's added to a summary that groups all the selections together. Here's how I want it to appear: Pizza Margarita 2x Pizza Sala ...

Having issues with the basic KnockoutJS binding not functioning as expected

There appears to be an issue with my KnockoutJS script that I'm struggling to pinpoint. Below is the snippet of HTML code: <h2>SendMessage</h2> <div class="form-group" id="messageSender"> <label>Select User Type</l ...

Struggling with CSS layout: Organizing and nesting divs

I am striving to create a layout like the one shown here: https://i.sstatic.net/LInER.jpg Presented below is my current HTML structure: <div id="main"> <div id="content1"> <span>Content1</span> <div id="text ...

What steps can I take to alter the background in this image?

After experimenting with webfilters, I attempted to alter the white background of this image in reference to: Change color of PNG image via CSS? I'm uncertain if this is the proper method to change the white background of the image located here: ht ...

Modifying line height with Jquery

Looking for help with my html code. I have a <div id="listview"> element with an unordered list inside containing a list item that has its height dynamically set using inline CSS. I'm trying to change the height of the list item using jQuery, bu ...

Looping Angular Components are executed

I am currently developing an Angular application and encountering an issue with my navbar getting looped. The problem arises when I navigate to the /home route, causing the navbar.component.html components to duplicate and appear stacked on top of each oth ...

Launch a bootstrap modal from a different webpage

If you're looking to open multiple modals with different content displayed from HTML files, check out this example below: <div id="how-rtm-works" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" ...