Table Scrollbar Solution

Here is a system I am working on: https://jsfiddle.net/p2fs68gm/2

I'm trying to add a scrollbar to the table, but when setting thead or tbody to display: block, their width decreases. I've attempted fixing the height of tbody and using overflow: auto, but it's not resolving the issue.

Answer №1

Make sure your table is wrapped inside a div with the style overflow:auto;height:80vh.

 table thead tr th {
  background-color: white;
  position: sticky;
  z-index: 100;
  top: -1px;
}
.container {
  margin: 50px;
}

/* Continue with CSS code snippet... */
<!DOCTYPE html>
<html lang="en">

<head>
  <title>Bootstrap Example</title>
  
  /* Continue with HTML markup... */

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

Looking to adjust line-height property for text with different line heights

I am struggling with adjusting the line-height of row-based text content in HTML enclosed in <p> tags. The challenge I'm facing is that the text could vary in length, resulting in either one or two lines. If it's a single line, it should co ...

Bootstrap navigation bar collapsing horizontally instead of vertically

My Navbar is collapsing correctly, but when I click the toggle icon after it's collapsed, the items appear in a horizontal row instead of the intended vertical block. I have checked the code on the Bootstrap 5 example page and tried to replicate it, b ...

Creating a Dynamic System for Converting Numeric Digits to Alphabetical Grades

Utilizing the code provided below, you can calculate a user's grade point average ranging from A+ to E-. Is there a way, within the following fiddle, to not only display the GPA but also convert it into a corresponding letter grade from A+ to E-? Curr ...

Mysterious empty area amidst two div elements

Check out this Fiddle link In my code, I have two containers - one for the header and the other for the main body. Inside the header container, there is another div that has been floated to the left. As a result of this floating element, there is now a wh ...

Only on mobile devices, Material-UI components spill over the screen

Update: This issue is isolated to one specific page. Other pages within the website are displaying correctly. Recently, I developed a web page using React and Material-UI. The main components utilized are Grid and Container. While the layout appears fine ...

Guide on inserting text within a Toggle Switch Component using React

Is there a way to insert text inside a Switch component in ReactJS? Specifically, I'm looking to add the text EN and PT within the Switch Component. I opted not to use any libraries for this. Instead, I crafted the component solely using CSS to achie ...

Fill the rest of the columns with Bootstrap styling

Is there a way to utilize a bootstrap class that will automatically fill up the remaining columns if some have already been occupied? For instance, if a specific div tag may or may not be present, I would like the second div to occupy 12 columns if the fir ...

Tips for comparing two arrays and displaying matching elements in separate columns

I am faced with the challenge of working with two arrays. The first array contains a list of all dates, while the second array holds the dates when a person is present. My objective is to generate a table that displays all the dates in the first row, and ...

Exploring the functionality of :nth-child() and :nth-of-type() selectors in action

While navigating my way through the world of self-taught CSS, I stumbled upon the pseudo-selector :nth-child() along with its counterparts :nth-last-child() and :nth-of-type(). I've delved deep enough to grasp the syntax and functionality, but still ...

Are you struggling with organizing fullcalendar events? Feeling overwhelmed by a challenging layout? Check out the image

Take a look at this mockup I have, and please excuse the chocolate smudges: From what I've observed in the HTML generated by fullcalendar, it seems impossible to achieve this layout. (It doesn't separate each day individually but instead arrange ...

The elements within the flexbox are being truncated when viewed on smaller devices

I have encountered an issue with my code where the .content element, which has flex properties, appears cut off on small screens. I want to avoid setting a fixed size because the text within it may vary in size. The goal is for the background image to fi ...

Resize drop zone with drag and drop functionality

I am using jQuery for dragging and dropping elements, but I am facing an issue. When I resize the drop zone while starting to drag an item, it seems like the previous size of the drop zone is still being used as the space. Is there a way to fix this? ...

Is there a substitute for HtmlUnit on Android?

Is there a different solution available that can help me complete an HTML form containing checkboxes and radio buttons? I was in the process of developing an Android application that requires user input, sends the data to a website with an HTML form, fill ...

When clicking on a dropdown option, the OnClick event does not seem

When selecting an option from the dropdown, it should retrieve a value from the database and display it in a text field. I implemented a click function which worked in Firefox but not in Google Chrome. HTML: <select id="classi" name="classi"> & ...

What is the best way to include multiple ng-repeats within a single ng-repeat?

Hey, I'm facing quite a tricky situation with this grid and could use some assistance. I'm trying to figure out how to populate the data using ng-repeat. I've attached an image showcasing the desired layout of the grid and the order in which ...

I would like to use a tabset row to showcase buttons in Angular 2

I need to arrange a tabset and buttons in a single row. The tabset is already displayed, now I just need to add the buttons. <div class="form-group col-sm-8 "> <div class="col-lg-8" style="margin-top:35px;" > <h6 class="text-rig ...

Customize the height of individual carousel items in Primeng carousel

Hey there, I'm currently using the primeng carousel component and running into an issue where the carousel height is always based on the tallest item. I am looking to have an automatic height for each individual carousel item instead. Do you think th ...

jQuery: Selecting both parent elements

Seeking a more efficient way to navigate through Divs using parent-child relationships. The current code is functional, but I am interested in finding a cleaner solution. Any suggestions on an easier method? Using jQuery selector: $(this).parent().parent ...

Combine two separate variables and insert them into a single cURL command line

I need to incorporate a random value from a variable into a cURL command. Additionally, I want the cURL command to execute a function using this random value. At the end of the function, I want to add a different value to the first one for completion and t ...

Both Fluid and Fixed layouts offer different advantages and disadvantages for website

Is there a way to position two divs side by side, where one div is 75% width and the other is 25% width? Additionally, can we place another div on top with margin:0 auto; to center the content of the page with a width of 986px? Here is an example code sni ...