Ensure that the second table header remains in a fixed position

One of my tables is scrollable horizontally while the other is not.

I'm looking to keep the header of the scrollable table fixed in place.

You can take a look at this jsfiddle link for reference.

The headers of the second table, which is enclosed in <div class="table2">, need to be made fixed.

What is the simplest way to accomplish this?

Answer №1

Are you looking for something like this? http://jsfiddle.net/Yw679/16/

It may not look perfect - the first table cell overlaps, but it meets your requirements.

UPDATE: Adjusted the header of table 2 to stay fixed.

Additional Update: Consider using the jQuery plugin recommended by Telemako.

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

Highlighting Search Results in Kendo TreeView

I am currently working on a KendoTreeview project with spriteclass. My goal is to highlight both the root and child nodes with a specific search term. I have successfully implemented the search functionality, however, there is an issue that arises after th ...

Shifting the MUI DataGrid Pagination table to the left with CustomPagination: A step-by-step guide

Hey everyone, I am currently diving into the MUI data grid to gain a better understanding. In order to meet my design requirements for a table view, I have incorporated the DataGrid component from MUI. For pagination, I am utilizing their custom implementa ...

Problems with JQuery Ajax Json Response

Provided Form Section: <script type="text/javascript" src="js/aboneol.js"></script> <h4>Subscribe</h4> <div class="newsletter"> <span id="aboneolerror">< ...

Navigating through JSON Serialization in Django and Unpacking JSON Data in Jquery

So here's the code snippet that I'm currently working with: def success_comment_post(request): if "c" in request.GET: c_id = request.GET["c"] comment = Comment.objects.get(pk=c_id) model = serializers.serialize("json" ...

Reveal the concealed button with a jQuery click event

I have a simple question that has been elusive to find an answer for on the internet. Can anyone please help? <input hidden="true" class="btnsubmit" id="myaddslide2" onClick="UPCURSLIDE()" type="button" value="UPDATE"> <script> function ...

The lua.vm.js ajax callbacks are triggering, but unfortunately, the requested data is not

After raising this issue at https://github.com/kripken/lua.vm.js/issues/5, I realized that submitting it to stackoverflow might yield a faster response due to higher exposure. To ensure clarity, I will restate my question: How can the callback data be acce ...

Tips for Adding Items to an Infinite Loop

Could you please review This Demo and advise me on how to continuously load items into the ul list in an endless manner? Currently, I have this code set up to display the list but I want it to keep adding new items to the end every time. var item = $(". ...

Stylish CSS animation enhancing an image

Can a flash effect like the one in this image be created using only CSS? I attempted to use -webkit-filter, but it did not produce satisfactory results. https://i.sstatic.net/Eg49c.jpg ...

Align text to the right and left side

HTML file: <div id="home"> <b><p class="split-para">java<br><a href="j_temp.html" class="float">temperature converter in terminal</a> <br> <a href="j_palindrom.html" class="float">palindrome checker</a& ...

Utilize dynamic CSS application within an Angular application

In my Angular application, I dynamically load URLs inside an iframe and want to apply custom.css to the loaded URL once it's inside the iframe. I attempted using ng-init with angular-css-injector function in the iframe, but the CSS is not being applie ...

Opentip parses the title attribute of table td elements and showcases it as the content

<table id="universal-radio-program" title="Uzej ar pelīti uz nosaukumu, lai redzētu aprakstu..."> <thead> <tr><th>&nbsp;</th><th scope="col">Pirmdiena</th><th scope="col">Otrdiena</th ...

Ending the loop of a jQuery JSON array when reaching the final row

I have a function that retrieves a JSON array and shows the results as a list with ten items. However, if there are fewer than ten results, it starts over from the beginning. This is my code: $.ajax({ url: 'http://www.entertainmentcocktail.com/c ...

Hiding elements in dark mode using `hidden` or `block` in Tailwind will not override its own hidden selector

To switch between dark and light mode for these two images, the dark:block selector does not override the hidden class. <div className="ml-5 content-center"> <img className="hidden dark:block h-6 w-auto my-1" src="/stati ...

Display the second ID when the click function is triggered

Hi there, I am facing an issue with a double click function. When the second element is clicked, the console displays a duplicate id error. However, if I move the console log to the first click, it only shows one log. How can I resolve this problem? My goa ...

Determine the height of the left div, which is set to auto, and apply the same height to the right div, which has overflow set

I am facing an issue that needs a solution. I need to ensure that two div elements have the same height. The left div should have 'auto' height while the right one must match it. Moreover, the right div contains 14 nested divs that need to be scr ...

Pause autoplay in Bootstrap v5.0 Carousel when a carousel item is clicked

I've been attempting to disable the carousel autoplay using jQuery after clicking on a carousel item, but all my efforts have been unsuccessful. Can anyone provide some assistance? Thank you! This is what I've tried so far: $(".carousel-i ...

Creating uniform line lengths with a ruler utilizing Fabric.js

I have a div that scrolls horizontally and contains a ruler div and a canvas where I draw horizontal lines of varying lengths. When drawing the lines, I want to ensure they are accurately measured against the ruler using JavaScript and CSS: var canvas = ...

How can you use a click event or a specific class to indicate voting on a submission with an arrow?

Is it more effective to utilize the approach utilized by reddit for voting, such as using <a onclick="vote('4')">, or should I simply include a class selector like <a class='vote-up' id='4'>? Or is the distinction ...

Troubleshooting JavaScript issues: jQuery not functioning as expected

Although I consider myself experienced in programming, my venture into jQuery has hit a roadblock with this seemingly simple code: $(document).ready(function() { $('.footer').click(function() { $('.footer').fadeOut('sl ...

Center the table element horizontally on an HTML page

I am facing an issue where my angular material and css table are not taking the full width of my div. Additionally, I want to set the image in the header as a background. Here is the link to my work on StackBlitz: https://stackblitz.com/github/lnquaidorsay ...