table that can be scrolled horizontally

I am facing an issue similar to the one discussed in this thread about responsive design for html wide table. In essence, my problem involves a table that is wider than the container div, which has ten columns in width (using bootstrap). The challenge arises when the table content exceeds the width of the container, causing the body of the table to get truncated. As a result, when I scroll horizontally, only the header of the table is visible while the body remains empty.

$('table').on('scroll', function () {
    $("table > *").width($("table").width() + $("table").scrollLeft());
});
.ten.columns {
    width: 82.6666666667%;
  }

  /* Offsets */
  .offset-by-one.column,
  .offset-by-one.columns {
    margin-left: 8.66666666667%;
  }
}

/* Other CSS styles for the table */
/* ... */
<div class='row ten columns offset-by-one'>
  <table>
      <thead>
          <tr>
              <th>Column 1</th>
              <th>Column 2</th>
              <th>Column 3</th>
              <th>Column 4</th>
          // Rest of the table content...
          </tr>
      </thead>
      <tbody>
          // Table rows...
      </tbody>
  </table>
</div>  

Answer №1

Modify this :

table thead, table tbody {
    display: block;
}

to :

table thead, table tbody {
    display: inline-block;
}

You could also try changing it to display: inline or display: table and it should function correctly.

Check out this link for a brief explanation on the variance between display: table, display: inline, display: block, and display: inline-block :

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

In my Cordova application, I am able to print the locally stored JSON array, but I am encountering an issue where the

Hello, I'm having some difficulties with JSON as a beginner. I've tried searching extensively but haven't found a solution that works for me. My issue arises when attempting to save data using local storage in JSON format - the array prints ...

Is there a way to insert the Ajax value into a PHP string in this particular scenario?

Is there a way to store the ajax result directly into a php string without using .html(), .text(), or .val() in the ajax success function? jQuery.ajax({ url:'member_search.php', type:'POST', data:{ search_text: $(".res ...

Utilize ASP to limit the application of a CSS file exclusively to the child page

My website consists of a master page and several child pages. I have created specific CSS classes for styling. However, I only want certain child pages to utilize these styles while the master page should always use them. How can I limit the access to th ...

What could be causing the div class to move downward in the CSS code?

I have posted a question, but unfortunately, no one has answered it yet. Here is my code snippet: * { margin: 0; padding: 0; } body { width: 100%; font-family: 'Cabin', sans-serif; background-color: #333; } .firstnav { ...

Prevent $.ajax with jQuery when a button is clicked

Is there a way to interrupt the $.ajax() function execution by clicking on this button: <button class="stop">Stop</button> Is there a specific function that can cause the $.ajax() call to stop? Note: The $.ajax script is within a function, l ...

How can I make <p> elements change color when scrolling?

My Goal https://i.sstatic.net/JbdXR.gif I aim to bring attention to the <p> element as the user scrolls on the page. Initially, the opacity is set to 0.3, but I want it to change to 1 gradually as the user scrolls down. My Attempt window.o ...

Execute a function within a different function once the ajax call has been completed

There's an issue with the timing of my function that runs inside another function. It seems like sometimes the ajax call to the server isn't completed before the function is called. function obtainPlans(row, user, id, type) { $.get( "/ ...

efficient method for generating href/src relative paths based on the current file within HTML tags

Recently, I've taken to using sublime text 2 and I'm on the lookout for a quick method to generate relative path references to use for creating hrefs or src links. For instance, imagine I have the following file structure: myfolder |-->css | ...

Implementing an active state for the 'a' tag within Bootstrap 5 nav-tabs in an MVC application can be achieved by utilizing ActionLink

In my .NET MVC application, I am utilizing Bootstrap 5.1 to create navigation tabs with 'a' tags generated via ActionLink. <ul class="nav nav-tabs"> <li class="nav-item"> @Html.ActionLink("Enti ...

Once the form is submitted, it is not validated and instead just refreshed

<html> <head> </head> <body> <script type="text/javascript" language="javascript"> function isUpperCase(str) { return str === str.toUpperCase(); } function validate() { var flag=0; var x=document.getElementById("f ...

Remove child elements in Jquery that do not match the specific numbers saved in the array

I've got this array: var numbersArray = [1, 2, 4, 5] and also an unordered list in HTML <ul> <li> item 1 </li> <li> item 2 </li> <li> item 3 </li> <li> item 4 </li> <li> item 5 ...

Looking to prevent horizontal scrolling on smartphones in an HTML webview - how can I do this?

Currently, I am dealing with a webview and encountering some peculiar behavior. The overflow-x property is set to hidden, which works perfectly on browsers. However, when accessed on a mobile device, the overflow seems to be ignored completely. Here is t ...

Adjusting the contenteditable feature to place the caret on a specific child node

I am experiencing some challenges when attempting to position the cursor after an <i> tag within a contenteditable element. Currently, this is what I have: <p contenteditable="true"><i>H</i><i>e</i><i>l</i> ...

I am experiencing a problem with a modal box in WordPress using bootstrap where I am unable to open videos on

I'm currently working on a WordPress site with a bootstrap theme. I am using a modal box to display videos on my page. My question is, can I have two different videos open on the same link? In other words, when I click on the link, one video will appe ...

Django Not Receiving Data from Ajax Request

I am trying to create a basic ajax method that will run once the document is fully loaded. The code I currently have in my JS file is as follows: $(document).ready(function() { $.ajax({ type:'GET', url: '/get_alert&a ...

Choose the value of the adjacent text input with jQuery

I am working with dynamic checkboxes and corresponding text inputs. My goal is to alert the value of the text input when a checkbox is checked. However, I am having trouble retrieving the correct value of the text input associated with each checkbox. Addit ...

Mouse cursor does not display as a pointer when utilizing an SVG image on Internet Explorer

Consider this html: <a href="http://www.wikipedia.com"> <object data="http://upload.wikimedia.org/wikipedia/en/4/4a/Commons-logo.svg" type="image/svg+xml"> <img src="http://herdeirodocaos.files.wordpress.com/2007/11/wikipedia-lo ...

The Angular service encounters issues when interacting with REST API

Within my application, a template is utilized: <div class="skills-filter-input" ng-class="{'hidden-xs': skillsFilterHidden}"> <input type="text" ng-model="skillQuery" ng-change="filterSkills()" placeholder="Filter skills" class="filter- ...

When the draggable item is released near the drop zone, allow drag and drop to combine

In my latest project, I created a fun game that involves matching different shapes. The goal is to drag the correct figure next to its corresponding shadow figure for a perfect match. Currently, if you partially overlap the square with its shadow, the game ...

I wish for the form to automatically shut down whenever I click on the (X) icon

I included a close button in my form, but it doesn't seem to be working. Do I need to use JavaScript for this? <button type="button" class="close" data-dismiss="form" aria-label="Close"><span aria-hidden="true">&times;</span>& ...