Table fixed header does not scroll with the content on the table

I am facing an issue with the design of my table where the header is fixed but the body scrolls horizontally on smaller devices, while the width of the table is set as a percentage value.

Below is the code I have:

.fixed_headers { width: 100%; table-layout: fixed; background: #ddd; border-radius: 5px; }
.fixed_headers thead { display: flex; border-radius: 5px 5px 0 0; }
.fixed_headers td { border-bottom: 1px solid #f00; }
.fixed_headers td,
.fixed_headers th { flex: 1 1; line-height: 40px; font-family: 'DIN Alternate'; font-size: 20px; text-align: left; padding: 0 10px; margin-top: 6px !important; }
.fixed_headers thead th, .fixed_headers thead th h5{ text-shadow: 1px 1px 3px #000; font-size: 20px; margin: 0; line-height: 32px; }
.fixed_headers tr{ display: flex !important; width: 100%; }
.fixed_headers thead { background-color: #f00; color: #fdfdfd; }
.fixed_headers td:nth-child(1),
.fixed_headers th:nth-child(1) { min-width: 100px; width: 20%; }
.fixed_headers td:nth-child(2),
...
<table class="fixed_headers" border="0" cellspacing="0" cellpadding="0" id="list">
   <thead>
      <tr>
         <th>
            <h5>DATA</h5>
         </th>
         <th>
            <h5>NOME COMPLETO</h5>
         ...
      </tbody>
  </table>

A solution to this problem would be greatly appreciated. Can someone please assist me?

Answer №1

To achieve the desired layout, it is recommended to divide your header and body into two separate tables with fixed column widths or utilize JavaScript for dynamic column adjustments. This setup allows for synchronized scrolling between the header and body when you scroll horizontally.

For a detailed solution, refer to this link:

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

Ways to ensure the footer sticks to the bottom of the page when there is minimal content

Using Bootstrap 3.3.7 I am trying to ensure that my footer always stays at the bottom of the browser window. I prefer not to use a "sticky footer" as I don't want it to cover any part of my content. Currently, when there is enough content on the pa ...

Creating a text-only fadein/fadeout carousel using JavaScript with a similar functionality to Bootstrap

Is there a way to create a fade-in/fade-out text only carousel similar to the one on the header of this website using just a few lines of CSS and Javascript instead of including the whole Bootstrap framework? I examined the code of the website and it appe ...

Achieving the perfect background image size using Tailwindcss

Looking for a way to use an image with a height of 300px and a width of 1600px as a background in a div element? Although the div element's height can be extended beyond 300px, it results in an empty space at the top while covering the width. The de ...

Assistance required for HTML, CSS, and jQuery

I have an image that I want to incorporate into my website in a unique way. Instead of simply uploading the whole image, I want to use HTML and CSS to add additional images and text onto the main background image. Despite reading multiple tutorials, I am s ...

The Vue component should trigger the display of data in a Bootstrap modal based on the row of the button that was

Here is a sample code snippet demonstrating how data is fetched from the database: <table class="table table-bordered"> <thead> <tr><th>User ID</th><th>Account Number</th><th>Accou ...

How to handle a situation where a React child component is blocking the

My child is currently preventing the parent method from being called when onMouseOver occurs. In order to gain a better understanding of the issue, I am including a code snippet and explaining what my desired outcome is. renderDropdown(){ let dropSt ...

Troubleshooting audio playback issues with create-react-app's componentDidMount method

When I set up my create-react-app project, I successfully imported jQuery as $ and used it in the componentDidMount() lifecycle hook. Within the render() method, I included: audio ref="bgAudio" source src={this.state.bgAudio} and initialized the stat ...

The panel's fullscreen feature crashes when exiting after triggering the 'resize' function

I'm facing an issue with a popup window that automatically goes into fullscreen mode. There are two buttons - one to exit fullscreen and another to simply close the window. When the window is in fullscreen, the exit button works perfectly. However, i ...

PHP code not linked with ODBC in HTML document

I must clarify that the title of this post could be misleading, and I apologize for any confusion caused. To address my current dilemma regarding SQL and ODBC: My objective is to set up a registration page on my website. Utilizing MYSQL on my dedicated se ...

Having difficulty inputting text into a text field using Selenium in Java

Here is a snippet of HTML code that I am working with: </td> <td valign=top bgcolor="#dcdcdc" class="camp"> <script>Oblog()</script>ID <br> <input ty ...

Python script using Selenium to only print elements in an HTML page that have a specific class value and print only certain elements based on

I am currently developing a script to automatically test all the free proxies available on The website contains a comprehensive list of all available proxies, and I have successfully made my script extract and display them. However, I only want to display ...

What is the method for applying a stroke-width:1 to specific sides of SVG shapes?

When setting a stroke-width: 1 on a <rect> element in SVG, typically a stroke is placed on every side of the rectangle. Is there a way to specify a stroke width on just three sides of an SVG rectangle? ...

Is the z-index functioning properly for the header call-to-action text on mobile devices, but not on desktop?

The desktop header cta is functioning properly, but when I switch to mobile nothing happens. I attempted to increase the z-index number within the html instead of in the style sheet. This is where my CTA is located in the html: CALL TO ACTION surrounded ...

Post the information from a webpage onto your Instagram story

I'm currently developing a web application that generates text content, with future plans to include images as well. I want to integrate a share button that allows users to easily add this generated content to their Instagram story. The intended flow ...

Embed a Google stylesheet link directly into a specific div within the HTML document

I had this idea of allowing users to choose fonts from Google and then take the URL to use in the template. Can a stylesheet link be directly placed on a div? Any assistance would be greatly appreciated! For example: <div id="post" href='http:/ ...

Uncommon problem with generating links

I am facing an issue with creating a link in the header bar of a website that was developed by another company. Despite having some HTML experience, I'm struggling to resolve this problem. The link I created for a page named gallery.php within the sam ...

Tips and tricks for ensuring images maintain their aspect ratio and height when resizing for responsiveness

I am facing an issue with my two-column layout. One column contains an image and the other column has text and buttons with a fixed height. To ensure the image is responsive, I have set the width to 100% and height to auto. However, upon resizing, the aspe ...

Can you help me identify the reason behind a page displaying a temporary horizontal scrollbar?

While browsing the following page in Google Chrome: A horizontal scrollbar appears briefly during page load. It seems that something hidden below the fold is causing this issue, but I haven't been able to identify the exact cause. EDIT:- Watch a v ...

Copying to the clipboard now includes the parent of the targeted element

Edit - More Information: Here is a simplified version of the sandbox: https://codesandbox.io/s/stupefied-leftpad-k6eek Check out the demo here: https://i.sstatic.net/2XHu1.jpg The issue does not seem to occur in Firefox, but it does in Chrome and other ...

What could be causing the span class data to not be retrieved by the getText method

Looking to retrieve the value of a span class called 'spacer-right big project-card-measure-secondary-info' <span class="spacer-right big project-card-measure-secondary-info">1</span> snippet of code: browser.waitForEl ...