div-based fixed-header table

My current project involves creating a table using only div elements, with the added challenge of having a fixed header so it remains visible while scrolling. The initial setup was looking good until I attempted to implement the fixed header:

Check out the implementation here

Unfortunately, when I applied the position: fixed, either the size of the header or the body started changing unexpectedly.

Answer №1

One option to consider is implementing the use of position:sticky, although it may not be fully supported across all browsers as indicated here. Alternatively, adding a margin-bottom to the header that matches the height of its cells could also achieve a similar effect.

Answer №2

Here is a suggestion:

.grid {
    display: grid;
    grid-template-columns: 20% auto;
    position: absolute;
}

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

Is there a way to automatically reset a datepicker using the on.change function?

I've attempted various methods to clear/reset the value for a datepicker using the on.(change) function, but have been unsuccessful. The Air Datepicker plugin is being used in conjunction with Bootstrap 4. HTML <select title="-- NODE --" id="node ...

Obtain the VW/VH coordinates from an onclick action in JavaScript

With this code snippet, you'll be able to retrieve the x and y coordinates of a click in pixels: document.getElementById("game").addEventListener("click", function(event) { console.log(event.clientX, event.clientY); }); However ...

Importing styles from an external URL using Angular-cli

How can I load CSS styles from an external URL? For instance, my domain is domain.eu but my site is located at sub.domain.eu. I want to use styles that are stored on the main domain (common for all sites). The example below does not work: "styles&qu ...

The alignment of the background images is off

I am attempting to give a container a background image and then create two div tags using the col-md-6 classes from Bootstrap. The main div's background image is of grass texture, while the two inner divs have a skeleton of a football court as their b ...

Is it acceptable to include a checkbox and a hidden input within a label element?

When creating a list of possible products for users to buy, I use the ul tag combined with li. Each product element includes a checkbox that allows users to select the product or not. For products with related information, I want to store this data in a h ...

Utilizing Bootstrap 5's table design to occupy the rest of the available vertical

In my .NET Core 7 MVC project, I am facing a challenge where I want to make a details table scroll and occupy the available vertical space on the screen dynamically. I have tried using h-25, h-50 classes to achieve the scrolling effect on the table. Howev ...

Loop through the ng-content elements and enclose each one within its own individual nested div

Although it is currently not supported, I am curious to know if anyone has discovered a clever solution to this problem. In my current setup, I have a parent component with the following template: <dxi-item location='after' class="osii-item- ...

How to position the play button in the center using Material UI and Flexbox

Seeking advice on achieving a centered play button with borders in this layout. Struggling with flexbox to position the play button within the code provided. function Tasks(props) { const { classes } = props; return ( <div className={classe ...

Steps to keep only one submenu open at a time and close others

Struggling to figure out how to open one submenu at a time, and I can't seem to locate the issue! I've searched around for solutions but haven't found anything that works for me. The submenu also needs to remain closed when the page loads. - ...

Express router is not functioning properly with the static CSS file

My current project involves using Express to create a login application, with EJS as the chosen template engine. The file structure of the application is as follows: package.json server.js routes index.js users.js views layouts.ejs login.ejs ...

Python: When scraping a table, only the tbody is returned without any content

Seeking to extract data from a table on this site: . Attempting to parse the HTML content of the table results in an empty body, as shown below: <thead> <tr> <th width="4%"> <div class="flex">#</div> </t ...

Exploring ways to maximize the width of responsive images on a webpage

I am currently working on a website located at . The slider image dimensions are set to 800x400, but the height appears too large. I need assistance in making the slider images responsive while maintaining their full width without sacrificing height. Ple ...

My observations on CSS challenges in IE7/8 and the Hashchange plugin

What is causing these float issues in Internet Explorer? Additionally, has anyone had any experience with 'jquery.ba-hashchange.min.js' and know how to make the hashchange function more visually appealing? Thank you! ...

The div content is aligning at the baseline rather than the middle

The social icons on my website are currently displaying at 40x40, with the text appearing below them. I am looking to center the text within the icons themselves. Any tips on how I can achieve this? Your help is much appreciated! Check out the fiddle here ...

What is the method for switching the pre font family back to the default Bootstrap 5 style?

The default font for <pre> tags in Bootstrap 5 is typically a monospaced style, which suits most coding and programming needs. However, I'm looking to utilize a <pre> tag for formatting a poem where line breaks are crucial. In this case, I ...

Enhance your website with Jquery-powered page transitions that can easily be linked for a

I have a client who has a specific vision for their website. To demonstrate the concept, I've created a demo which can be viewed here: She requested page transitions similar to those in the demo for the main content. I used jQuery to implement this ...

The code for the submit button functions properly in Firefox, but encounters issues in Internet Explorer

While this code functions correctly in Firefox, it fails to work in IE8. <a class="sub"> <input type="submit" a="" none;<="" display:=""> </a> Although the button appears on the page, it is not clickable in IE8. Can you help explain ...

Alignment problem detected in Firefox and Safari, but works perfectly in Chrome

Currently dealing with a CSS problem on my website that is only appearing in Safari and Firefox, while Chrome displays it correctly. The images are not positioning correctly and are stacking instead of being placed in each box as intended. I've expe ...

Centered at the bottom of the screen lies a Bootstrap button

As a beginner with bootstrap, I am currently exploring new concepts and experimenting with different features. One thing I am attempting is to center a bootstrap button at the bottom of the screen. Here is my current code: .bottom-center { position: a ...

Tips for: Minus a CSS property from a JavaScript variable height?

Is there a way to deduct the navbar_height by 2rem in the code snippet below? navbar_height = document.querySelector(".navbar").offsetHeight; document.body.style.paddingTop = (navbar_height - 2 ) + "px"; Appreciate your help! ...