What are some ways to correct the header of a table with an unfixed width?

I'm dealing with a table that allows users to add new columns, resulting in variable widths. How can I keep the header fixed for this type of table?

My attempted solution:

display:block
overflow-x:hidden
overflow-y:auto 
height:70%

Incorporating this into the table body yielded partial success.

Answer №1

It seems like you are asking about nesting a table inside an extendable part in your HTML code. By doing this, you can add multiple columns (<td>) without affecting the table header.

table td table td {
  border: solid 1px grey;
  }
<table>
  <tr>
    <th>Include your fixed table header here</th>
  </tr>
  <tr>
    <td>
      <table>
        <tr>
          <td>New columns</td>
          <td>can be added</td>
          <td>without affecting the header</td>
        </tr>
      </table>
    </td>
  </tr>
</table>

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 bypass a transition using JavaScript

Hello everyone, I would like to start by apologizing for any mistakes in my English. I have been working on a website, which is currently available here: As you scroll down, the height of the image below the menu decreases. I am trying to make the navig ...

Using jQuery to animate the opacity to 0 and then smoothly fade out the element

I am currently working on a function that animates the opacity of an element to 0 as the user scrolls. However, I am facing an issue where the element is fading out too early instead of waiting for the animation to finish. Here is a link to my jsFiddle sho ...

How to apply bold styling to text with DOM Events

I am currently in the process of learning JavaScript and decided to practice by creating a text editor. The goal is to type something, click a button to change it to upper or lower case, bold, or italicize. While I successfully implemented the uppercase an ...

JavaScript - Insert rows within the tbody element by adding them after the opening tbody tag. The new rows should be

Having trouble adding rows in JavaScript. The code is functioning correctly, but the new rows are appearing after the tbody tag instead of inside it. Here's a snippet of the code: function deleteRow(row) { var i = row.parentNode.parentNode.rowIn ...

Sticky footer in Bootstrap causing content to overlap

I'm a beginner when it comes to Bootstrap, and I'm attempting to integrate it with Symfony2. I currently have a sticky top bar in place for navigation purposes. However, I'm facing an issue when I try to add a similar sticky footer at the bo ...

Struggling to properly position a search input and submit button in a navbar on smaller screens

While creating a search view for a website, I noticed that the search box and submit button placed next to it (aligned to the right at most screen widths) would become misaligned in very small max-widths. Using Bootstrap 4, I utilized ".ml-auto" to align ...

Pause animation when hovering over their current positions

I am working on a project with two separate divs, each containing a circle and a smiley face. The innercircle1 div is currently rotating with a predefined animation. My goal is to create an effect where hovering over the innercircle1 div will pause its rot ...

Toggle visibility of divs on button click

let loginBtn = document.getElementById("btn-login"); let loginDiv = document.getElementById("loglog"); let signupBtn = document.getElementById("btn-signup"); let signupDiv = document.getElementById("signMe"); loginBtn.addEventListener("click", () => { ...

Elevate Your Flipclock.js

I am currently working on a website that utilizes flipclock.js, but I am facing some challenges in enlarging it to occupy more space on the page. Is there anyone who knows how to upscale or increase its size? ...

Ways to toggle the visibility of HTML table rows periodically

I've been working with HTML tables, where I created a dynamic table split into four columns for display. Now, my task is to show 5 rows at a time on the screen using CSS. To achieve this, I'm populating the table in one go and refreshing the cont ...

Is it possible for me to conduct a compatibility test on Safari 7.0 in Windows 8.x on my

Currently, as I work on developing my web application on a Windows 8.x machine, I am making updates to ensure support for the Flexible Box Layout Module. Testing the design in Chrome and IE is straightforward, but I'm facing challenges when it comes ...

How can you activate color printing in CSS when using ng-style in AngularJS?

My application generates data in a table, where each cell has a unique combination of background color and text color determined by its properties. The code to achieve this is simple: ng-style='{"background-color": lt.backgroundColor, "color": lt.te ...

Is there a way to determine the dimensions of an element that is set to "display: none"?

Is it possible to retrieve the dimensions of child elements inside a div that has been hidden with CSS property display: none? If so, how can this be achieved? Check out the Fiddle Demo here var o = document.getElementById('output&apos ...

Modify the styling of multiple divs using a loop when the page is first loaded

I am working on a loop that generates multiple boxes with masonry layout containing post excerpts. <div class="box"> <div class="image"> <img src="" /> </div> <div class="info"> <h3>//title output with ...

Ways to create a noticeable effect on an image button when hovering without causing a shift in the position

Check out my simple script here: http://jsfiddle.net/PA9Sf/ I am looking to make a specific button stand out when hovered over without affecting the position of other buttons on the page. The current implementation in the provided jsfiddle moves the butto ...

How can I add styling to materializecss chip elements?

When working with tags on a web page, Materializecss makes it easy. However, I have a requirement where the tags need to be of different colors based on their types. Although this is feasible, another complication arises when supporting Materializecss keyb ...

Including new styles in CKEDITOR.stylesSet that pertain to multiple elements

My idea involves creating a unique bullet list style with two specific features: a. A blue arrow image replacing the standard list icon b. Very subtle dotted borders above and below each list item. I am looking to incorporate this design into CKEditor t ...

Tips for aligning vertical text perfectly

After spending the entire day researching vertical text, I am still struggling to find a simple solution. I need three items in my header to line up horizontally: an image on the left, a specific-sized box in the center, and another image on the right. Her ...

Align Bootstrap rows within separate columns

Following is the layout breakdown: Green: row Purple: column Blue, Orange, Gray: a row respectively The green rows can stack on smaller screens. How do I achieve this layout? Currently, the greens are not available to stack, but I can align the blue, ora ...

What is the method for printing background images/styles without adjusting the browser's page setup?

Is there a method to maintain row striping in the printout like it appears on screen? <div id="test" style="background:#000000; color:#FFFFFF">Black Stripe</div> I would like to create a page with consistent row stripe formatting for printing ...