"Using the d-flex class with Bootstrap 4 tables does not allow them to expand to

Since the latest version of Bootstrap 4, it has become more challenging to apply classes like col-md-2 directly to the tr or td elements of a table.

A possible solution is to use class="d-flex" in the parent element:

<tr class="d-flex">

However, when I implement this solution, my entire table no longer fits within the parent div. I am struggling to find a workaround for this issue.

https://i.sstatic.net/Pmy21.png

I would greatly appreciate any assistance in finding a way to resolve this issue. Here is the code snippet of the table in question:

<div class="card-body">
   <h3 class="col-12 mt-2">Lehrer</h3>
   <table class="table table-light">
       <tbody>
            <tr class="d-flex">
                <td class="col-md-1">Florian</td>
                <td class="col-md-2">Wassermair</td>
                <td class="col-md-4">Schulbuchbeauftragter</td>

                <td class="col-md-1">
                   <a class="btn btn-primary" href="/profile/show/4">
                      <i class="icon icon-eye"></i>
                   </a>
                </td>

                <td class="col-md-1">
                   <a class="btn btn-success" href="/personal/4/edit">
                       <i class="icon icon-edit"></i>
                   </a>
                </td>
           </tr>

           <tr class="d-flex">
                <td class="col-md-1">Bernadette</td>
                <td class="col-md-2">Mayr</td>
                <td class="col-md-4"></td>

                <td class="col-md-1">
                    <a class="btn btn-primary" href="/profile/show/3">
                        <i class="icon icon-eye"></i>
                    </a>
                </td>

                <td class="col-md-1">
                    <a class="btn btn-success" href="/personal/6/edit">
                        <i class="icon icon-edit"></i>
                    </a>
                </td>
           </tr>                                                                                         
      </tbody>
   </table>
</div>

Answer №1

To ensure the table cells fill the width completely, you can utilize 12 columns units...

<tr class="row mx-0">
    <td class="col-md-2">Bernadette</td>
    <td class="col-md-2">Mayr</td>
    <td class="col-md-6"></td>
    <td class="col-md-1">
        <a class="btn btn-primary" href="/profile/show/3">
            <i class="icon icon-eye"></i>
        </a>
    </td>
    <td class="col-md-1">
        <a class="btn btn-success" href="/personal/6/edit">
            <i class="icon icon-pencil"></i>
        </a>
    </td>
</tr>

Alternatively, use ml-auto to shift the columns to the right..

<tr class="row mx-0">
    <td class="col-md-2">Florian</td>
    <td class="col-md-2">Wassermair</td>
    <td class="col-md-4">Schulbuchbeauftragter</td>
    <td class="col-md-1 ml-auto">
        <a class="btn btn-primary" href="/profile/show/4">
            <i class="icon icon-eye"></i>
        </a>
    </td>
    <td class="col-md-1">
        <a class="btn btn-success" href="/personal/4/edit">
            <i class="icon icon-pencil"></i>
        </a>
    </td>
</tr>

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

Retrieve the data from an input field in Selenium automation

Despite the text being visible in the input Text Box, I am encountering difficulties capturing it from the html DOM. I attempted to use getAttribute('value'), however, since the value attribute is not present, this method proved unsuccessful. Sim ...

The MinWidth property in ColumnDefinition is not functioning as expected

Currently, I am encountering an unusual issue while using a Grid in WPF (XAML) and setting the MinWidth property in a ColumnDefinition. When I have 9 ColumnDefinitions with 'Width="*"' specified for each one, and then apply the MinWidth property ...

Retrieving data from a database in PHP and assigning it as the value for an HTML select tag

Seeking assistance on a project to develop a stock management system for an herb factory using PHP with a MySQL database. Currently working on a page that allows the user to edit the value of a bench containing herbs. The bench details have been stored in ...

Enhancing button images with gradient effects on hover

I'm currently working on adding a color gradient effect to a PNG graphic used as a button. I specifically want the color gradient to appear only when the user hovers over the image, and not just for background images like most solutions seem to provid ...

Utilize CSS with dynamically created elements

I am currently figuring out how to use my .each() function with a $(document).ready and a click event. Here's what I have so far: $(document).ready(function(){ $(".help-inline").each(function() { $(this).css('display', 'none&apos ...

Top Tip for conditionally rendering a styled component inside or outside a wrapper, depending on the screen width

Can anyone help me with this coding question? I'm currently trying to determine the most efficient way to conditionally place the code inside or outside of the wrapper. However, I am unsure what the best practice for this would be. This process seems ...

The foundation grid system is not being implemented

How come my div is not affected by the foundation grid system: render: function(){ var {todos,showCompleted,searchText} = this.state; var filteredTodos = TodoAPI.filterTodos(todos,showCompleted,searchText); return ( <div> ...

When examining an element in an Angular application using Chrome Dev Tools, why do I not observe raw HTML code?

Just as the title suggests, my question is: Even if browsers don't understand Angular, why am I able to see Angular elements while inspecting the DOM despite using AOT (Ahead-Of-Time Compilation) which means there is no Angular compiler in the browse ...

How to eliminate spacing between photos in a flexbox layout

[Unique] Find the Solution Image inside div has extra space below the image My design showcases various images of different sizes in multiple rows. See an example here. Despite my efforts, there are noticeable gaps between the rows that I can't seem ...

The attempt to showcase items in a div element using inline display did not produce

I am having trouble with creating a webpage. I have designed a website but I am struggling to get it right. I have included my HTML and CSS code below. What I am trying to achieve is a header at the top, followed by several sections containing a photo on ...

Customizing the appearance of checkboxes in React Material-Table filtering feature

Is there a way to modify the style of checkboxes in filtering? For instance, if I wish to adjust the dimensions of the checkbox that appears for the Birth Place field, what steps should I take? https://i.stack.imgur.com/pZLqQ.png ...

Styling with floated divs in CSS

I'm facing a rather unique issue while working on creating a menu for a web page. The main challenge lies in ensuring that the parent element containing floated child divs adjusts its height dynamically, especially when changes are made to the padding ...

Using JavaScript to create circular shapes on canvas with paint circle

I need assistance in JavaScript to create a circle and update it while removing the previous one. My current code is: <html> <head> <style> body { margin: 0px; padding: 0px; } </style> </head> <body> <ca ...

Action of Submit Button Based on Field Matching Another Form

I currently have a single page that contains two forms, with only one form being displayed at the moment. The concept is that if the user selects a specific state from the drop-down menu and clicks on the submit button, they will be redirected to either a ...

What is the distinction between selecting and entering a date input value?

When a user selects a date, it needs to be immediately sent to the server. If they manually type in the date, it should be sent on blur. The issue arises when the oninput event is triggered for each keydown event, causing unnecessary server requests while ...

Error code 302 is triggered when attempting to retrieve an HTML file from a web address

I'm having trouble retrieving the HTML document from the URL provided below: The issue is that I keep getting a 302 response code! I am not very familiar with how this request is being handled (with the function and parameters), so I am unsure of the ...

Unable to scroll through embed code on iOS responsive devices

-webkit-overflow-scrolling: touch; overflow-y: scroll; I have attempted using this code but unfortunately it is still not functioning as expected. The issue seems to only occur on iOS responsive devices, as it works fine on other devices including MAC. ...

Retrieving text snippet from an HTML document using .NET

Users input HTML content using a richtext editor, allowing for a variety of elements. Here is an example of such content: <h1>Header 1</h1> <p>Some text here</p><p>Some more text here</p> <div align=right><a hr ...

Generate additional tabs

Currently, I am in the process of working on a project where I have a bar that will contain dynamically filled tabs. My goal is to include a (+) image that becomes visible when the bar is full. When a user clicks on this image, the remaining tabs should ap ...

An instructional HTML/JS dialogue for a linked page

On my website, there is a link that, when clicked, opens a new tab with a page that I don't control. I want to guide the user on what to do next after they are redirected to this new page ("Now please press the green button on this page"). Ideally, I ...