What is the best way to increase the width of Bootstrap responsive tables?

When using Bootstrap 5 to create responsive tables, I encountered an issue where columns with a lot of text caused other columns to get squished, resulting in a weird appearance. I am looking for a way to prevent this by ensuring that columns with less text and the table headers do not get cut off. The table is set to be responsive, which in Bootstrap's CSS includes overflow-x: auto.

Here is a picture of how the table looks on mobile

Second mobile view picture

Here is what it looks like on PC

<head>
    <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="72101d1d06010600130232475c425c425f1017061343">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">    
</head>
<div class="container"> 
   <div class="table-responsive">
      <table class="table table-sm table-bordered table-hover">
        <thead class="table-warning">  
                <tr>  
                    <th scope="col">Ticket ID</th> 
                    <th scope="col">Asset Type Or User</th>
                    <th scope="col">Asset Tag</th>
                    <th scope="col">User ID</th>
                    <th scope="col">Name</th>  
                    <th scope="col">Location</th> 
                    <th scope="col">Description</th> 
                    <th scope="col">Date Added</th> 
                    <th scope="col">Priority</th> 
                    <th scope="col">Mark As Done</th>
                </tr>  
            </thead>  
            <tbody>
                <tr>
                    <th scope="row">4</th>
                    <td>computer</td>
                    <td>C-Place-Holder</td>
                    <td>NA</td>
                    <td>Tom Blow</td>
                    <td>In Health Building, Bottom Floor</td>
                    <td>User would like to print color, has missing files, and monitor is flickering.</td>
                    <td>2021-02-24</td>
                    <td>3</td>
                    <td>
                    <button class="btn btn-primary" id="4" onclick="markDone(4)">Done</button>
                    </td>
                </tr>
            </tbody>
        </table>  
    </div>
</div>

Answer №1

In order to achieve a complete 100% result, you will need to incorporate the following CSS command:

.table-responsive { display: table; }
However, please note that this method may not be effective for smaller screens. You may have to resort to utilizing media queries to address this issue. I trust that my explanation has been of assistance to you.

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

Tips for designing a dropdown menu for selecting the number of passengers

Looking for guidance on adding a passenger count dropdown form similar to the one in the image below. I've searched everywhere but can't find a demo or any help. Can someone assist me with this? https://i.sstatic.net/RO1vi.jpg Appreciate any he ...

What steps should I take to address these styling challenges?

Recently, I came across some code that uses the hspace attribute which is now considered outdated. In order to create space between elements in a widget, I am looking for a solution that involves adding 10px of space above and between the items using CSS. ...

Using jQuery to pass UI positions as percentages instead of screen positions

Currently, I have implemented the following code to send $_GET values to a PHP page: $.get('/includes/sticky_notes/update_position.php',{ x : ui.position.left, y : ui.position.top, z : zIndex, id : parseInt(ui. ...

Assign an id to a div container once the onClick event activates the component

Can someone help me with the best way to set an id called "editorial-slider" when the triggerEdSlider() function is triggered? Here's what I have tried so far: const [containerId, setContainerId] = useState('.slider'); // Initial className t ...

Directive isolated scope is encountering an undefined $scope variable

After searching through various Stack Overflow posts on the issue, I have tried different solutions but still can't get my directive to render. The goal is to pass an integer to my directive within an ng-repeat loop and display an emoji based on that ...

Having trouble with the Python for loop functioning incorrectly?

I'm facing issues with my for loop in my Django application. I'm attempting to display other users who have logged in under "Users who could be friends," but nothing is appearing. I believe my app will function correctly once I resolve this issue ...

Is it possible to run a Vue file autonomously, similar to an HTML file

When it comes to running html, we can rely on mainstream browsers such as Chrome. But is there a similar tool for vue files, like the browsers designed for html? ...

Bringing together the convenience of an auto slider with the precision of a

I am looking to create a slider that combines automatic sliding with the option for manual control. Ideally, the slider would change photos automatically but also allow users to manually switch using previous/next buttons or small dots. I have searched for ...

Incorporate personalized design elements within the popup component of Material-UI's DataGrid Toolbar

I am in the process of customizing a Data Grid Toolbar component by making adjustments to the existing Grid Toolbar components sourced from Material-UI. For reference, you can view the official example of the Grid Toolbar components here. Upon clicking o ...

What is the process for removing a full row from a table in PHP?

Is there a way to add a delete button to delete an entire row in a MySQL database? Below you can find the code and instructions on how to delete a row using the ID, which is the primary key. <?php mysql_connect('localhost', 'off', ...

Adjusting the scope value directly within a directive

I have a validation message that starts off hidden when the page loads due to the ng-show attribute. When the user clicks to delete an entry, the confirmation message for successful deletion appears by changing the ng-show value to false. Now, I need to h ...

How can a single value (the clicked one) be retrieved from a for loop using addEventListener in a Django project with JavaScript

Struggling to integrate JS into my Django project, I received the following message in the console: HTMLCollection(2) [p.currency-one, p.currency-one] HTMLCollection(2) [input.amount-one, input.amount-one] app.js:21 Uncaught TypeError: c1.addEventListener ...

Having trouble getting the popover window to appear in Bootstrap when utilizing the modal class?

I attempted to create a responsive image gallery using the bootstrap framework. Each image has its own modal class, but when I click on an image, no popup window appears, only a dark screen is displayed. I have checked this in the Bootstrap documentation ...

Using colored circles in ASP Dropdownlist ListItems (without jQuery): A step-by-step guide

Objective: To create a Dropdown list that displays a green circle if someone's Availability is True, and a red circle if someone's Availability is False. Note: The task needs to be accomplished without the use of jQuery, as it is restricted in t ...

Click here to access the identical page

Longtime follower of stackoverflow but only my second time posting a question. Here is the code I am currently working on: echo "<td><a href = 'http://localhost/map/index.php' value='$id' >Delete</a></td>"; ...

Switching Div Elements Created by PHP

Utilizing MySQL, I am fetching data to dynamically generate nested div tags in a hierarchical structure. This structure consists of div tags within div tags within div tags, all uniquely identified through PHP-generated ids: <div class="holder"> ...

Automatically Dismissing a Bootstrap Alert After a Set Number of Seconds

Having some trouble closing a Bootstrap alert automatically on my new site built using the Bootstrap Framework. The issue arises when trying to close the alert after a certain amount of time. On the main page of the site, there is a modal login form. When ...

Change the opacity of a DIV or any other element when hovering over it

I have successfully applied opacity: 1; to a paragraph when hovering over itself. However, I want the opacity to also change when hovering over the header above it. Here is my CSS code: .testH { font-family: impact; text-align: center; font-s ...

Preventing the last letter from being cut off when using overflow:hidden

Check out this code snippet below... .panel { width:400px; overflow:hidden; background:lightgrey; font-size:30px; } <div class="panel"> This is a sample text to demonstrate the overflow property in CSS. We want to ensure that it do ...

Creating a standalone Wordpress child theme with its own CSS

After creating a child theme based on the responsive i-transform theme from http://templatesnext.org/itrans/, I found myself continuously undoing the i-transform CSS, which is taking up a lot of my time. However, if I remove the entire parent stylesheet, t ...