Enhance the responsiveness of Bootstrap 4 table columns to efficiently display content by widening the width

Incorporating Bootstrap's 4 responsive tables has proven beneficial for displaying tabular data. However, a challenge arises when some data cells are required to hold a substantial amount of information, such as a couple of lengthy sentences. In these cases, the column containing the information remains narrow and fails to expand adequately to showcase the data effectively, as illustrated in image 1 https://i.sstatic.net/Lncvj.png.

Despite seeking guidance on Stackoverflow, a suitable solution remains elusive. Attempting to utilize various col classes, like col-6, to adjust the width of the column housing the extensive information yielded no successful results. It appears that the columns maintain equal width and do not dynamically adjust based on the content within the data cell.

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e2808d8d969196908392a2d6ccd1ccd3">[email protected]</a>/dist/js/bootstrap.min.js"></script>
<link href="https://cdn.usebootstrap.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>

<!-- start table -->
<div class="table-responsive mdb-shadow-4-strong my-5">
<table class="table table-bordered table-striped" style="border-collapse: collapse; width: 100%; border-width: 1px;" border="1"><caption><strong>Tabel x.</strong> Sample Table Caption</caption>
<thead>
<tr>
<th scope="col" style="text-align: center; width: 18.941%; border-width: 1px;">
<p>Code</p>
</th>
<th scope="col" style="text-align: center; width: 18.941%; border-width: 1px;">Leeruitkomst</th>
<th scope="col" style="text-align: center; width: 29.8106%; border-width: 1px;">Beschrijving Leeruitkomst</th>
<th scope="col" style="text-align: center; width: 32.2128%; border-width: 1px;">Aantal EC's</th>
<th scope="col" style="text-align: center; width: 4.37778%; border-width: 1px;">NLQF</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center; width: 18.941%; border-width: 1px;">
<p>A</p>
</td>
<td style="width: 18.941%; border-width: 1px;">
<p>Totale zorg in kaart brengen aan de hand van het verpleegkundig proces</p>
</td>
<td style="width: 29.8106%; border-width: 1px;">
<p>De verpleegkundige brengt de totale zorg voor een zorgvrager zelfstandig in kaart met behulp van klinisch redeneren. Hierbij doorloopt de verpleegkundige de verschillende fasen van het verpleegkundig proces. De totale zorg vindt plaats in een authentieke leeromgeving gericht op een acute, instabiele situatie. Hierbij observeert, monitort en interpreteert de verpleegkundige de vitale functies. Bij het analyseren van de casus maakt de verpleegkundige gebruik van passende methodieken, waarbij in de analyse gebruik gemaakt wordt van medische kennis, richtlijnen, protocollen, wet- en regelgeving en Evidence-Based Practice. Vanuit deze analyse prioriteert de verpleegkundige de interventies, en houdt hierbij rekening met de persoonlijke situatie van de zorgvrager.</p>
</td>
<td style="text-align: center; width: 32.2128%; border-width: 1px;">
<p>15</p>
</td>
<td style="text-align: center; width: 4.37778%; border-width: 1px;">
<p>6</p>
</td>
</tr>
<tr>
<td style="text-align: center; width: 18.941%; border-width: 1px;">
<p>B</p>
</td>
<td style="width: 18.941%; border-width: 1px;">
<p>Methodisch uitvoeren van zorg en communicatie rondom het verpleegkundig proces in een gesimuleerde authentieke leeromgeving</p>
</td>
<td style="width: 29.8106%; border-width: 1px;">
<p>De verpleegkundige is in staat om zelfstandig in een gesimuleerde authentieke leeromgeving, gericht op een acute, instabiele situatie methodisch te handelen en passende interventies in te zetten. Hierbij richt de verpleegkundige een veilige en efficiënte werkomgeving in en onderhoudt deze tijdens het verlenen van zorg. De verpleegkundige benadert de zorgvrager op professionele en respectvolle wijze. De verpleegkundige toont leiderschap in de communicatie en samenwerking met betrokken professionals. De verpleegkundige toont professionele verantwoordelijkheid tijdens het verpleegkundig proces en kan hier methodisch op reflecteren met aandacht voor gebruikte kennis, vaardigheden en attitude. </p>
</td>
<td style="text-align: center; width: 32.2128%; border-width: 1px;">
<p>15</p>
</td>
<td style="text-align: center; width: 4.37778%; border-width: 1px;">
<p>6</p>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end table -->

Is there a glaringly obvious aspect I am overlooking? Are there specific Bootstrap 4 classes that could resolve this issue?

Answer №1

I have removed all the inline styling from <th style="...">. The default layout is already quite attractive and meets your requirements, doesn't it?

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b6d4d9d9c2c5c2c4d7c6f68298859887">[email protected]</a>/dist/js/bootstrap.min.js"></script>
<link href="https://cdn.usebootstrap.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />

<!-- start table -->
<div class="table-responsive mdb-shadow-4-strong my-5">
  <table class="table table-bordered table-striped">
    <caption><strong>Table x.</strong> Sample Table Caption</caption>
    <thead>
      <tr>
        <th scope="col">
          <p>Code</p>
        </th>
        <th scope="col">Learning Outcome</th>
        <th scope="col">Description Learning Outcome</th>
        <th scope="col">EC's</th>
        <th scope="col">NLQF</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>
          <p>A</p>
        </td>
        <td>
          <p>Comprehensive assessment of care based on the nursing process</p>
        </td>
        <td>
          <p>The nurse independently assesses the total care for a patient using clinical reasoning. This involves going through the different stages of the nursing process. Total care takes place in an authentic learning environment focused on an acute, unstable situation. Here, the nurse observes, monitors, and interprets vital signs. In analyzing the case, the nurse uses appropriate methodologies, including medical knowledge, guidelines, protocols, laws and regulations, and Evidence-Based Practice. Based on this analysis, the nurse prioritizes interventions, taking into account the patient's personal situation.</p>
        </td>
        <td>
          <p>15</p>
        </td>
        <td>
          <p>6</p>
        </td>
      </tr>
      <tr>
        <td>
          <p>B</p>
        </td>
        <td>
          <p>Methodical execution of care and communication surrounding the nursing process in a simulated authentic learning environment</p>
        </td>
        <td>
          <p>The nurse is able to independently act methodically in a simulated authentic learning environment focused on an acute, unstable situation and implement appropriate interventions. The nurse creates a safe and efficient working environment and maintains it while providing care. The nurse approaches the patient in a professional and respectful manner. The nurse demonstrates leadership in communication and collaboration with involved professionals. The nurse shows professional responsibility during the nursing process and can reflect on it methodically with attention to the knowledge, skills, and attitudes used.</p>
        </td>
        <td>
          <p>15</p>
        </td>
        <td>
          <p>6</p>
        </td>
      </tr>
    </tbody>
  </table>
</div>
<!-- end table -->

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

Remove multiselect label in PrimeNG

I am attempting to change the multiselect label of selected items and replace it with a static default label. Here is what it currently shows: https://i.sstatic.net/qBNHG.png This is what I have tried: .p-multiselect-label { visibility: collapse; ...

The flex item does not appear as intended when styled with justify-content: space-between

I'm trying to create a menu bar with sub-menus in CSS using Flexbox. I want to have an "Account" or "Profile" link on the right side of the menu bar on the same line, but for some reason, it's displaying under the main menu. I believe there' ...

What is the best way to incorporate the parallax effect into a v-carousel?

Currently, I have a "v-carousel" containing multiple images and now I am looking to incorporate a parallax effect into it, similar to "v-parallax". <v-carousel cycle height="600" hide-delimiter-background show-arrows-on-hover> <v-carousel-i ...

Identifying shifts in offsetTop

In my design, I have a page where scroll bars are not allowed, meaning all content must be visible at once. The image below shows the basic layout of the screen to give you an idea. The layout consists of two blocks - Block 1 and Block 2. Block 1 is expan ...

ReactJS - Element not specified

I'm experiencing a specific issue with the component below related to the changeColor() function, which is triggering an error message: TypeError: Cannot set property 'color' of undefined This error seems to be isolated within this compo ...

Arrange your grid system with Bootstrap Vue

There is a dataset retrieved from an API, and each item will be displayed within a div using a v-for loop. The desired layout for the grid of divs is as follows: [-- item 1 --][-- item-2 --] [-- item 3 --][-- item-4 --] [-- item 5 --][-- item-6 --] [-- ite ...

Aligment issues in columns on Bootstrap 5

I currently have a layout using Bootstrap 5 with multiple rows and columns. My goal is to have the columns aligned within each row, but I am experiencing issues where some borders are not lining up correctly with the columns. .VI-border { border-t ...

Tips for designing an Ionic app with a Pinterest-inspired layout

Recently stepping into the world of Ionic development, I find myself facing a challenge in creating a Pinterest-inspired layout using Ionic. Specifically, I am struggling to achieve a two-wide list of items with varying heights. Can anyone offer guidance ...

Tips for Changing Background Color Beyond Body Tag

When using my demo below on Safari for iOS and scrolling up and down, you'll notice that you can scroll outside of the body until removing your finger from the touchscreen. The background color outside of the body is white. Is there a way to change th ...

What is the best way to remove the background transparency of an image?

Images are being shown inside an HTML table using PHP code : This is the code for the table : for ($i = 0; $i < $data['list']['cnt']; $i++) { $tabRows[$i][1]['width'] = "45%"; $tabRows[$i][1][&apos ...

"Stylish hover effect for list items using CSS arrows

I'm struggling with creating a list menu that has a 1px border and spans the entire width. Here is what I have so far (image 1): https://i.stack.imgur.com/y3EDP.png The tricky part is making it so that when the mouse hovers over a menu item, someth ...

How to alter the color of an inline SVG within an <img> element

Is it possible to change the color of an SVG image, icon, or logo within an inline HTML <img> tag using style="..."? Below is a snippet of my code featuring a button with a logo that I want to change the color of: <a href="#" ...

Dynamic Navbar that Adapts to Your Scroll

I'm experiencing an issue with my navbar. I want it to stay at the top of the page when I scroll, but whenever I apply the "position: fixed;" property, the navbar disappears. Below is my HTML and CSS code: <nav> <div class="navbar"> <b ...

Background and border presentation issues arising from CSS conflict

While working on a webpage, I encountered a design conflict within a div that contains a group of other div elements. The current appearance can be seen at , and the desired look is shown in the image here: enter image description here ...

Divide the division inside the box by clicking on it

I am looking to create a unique div with a random background color and a width of 100px. Additionally, I want to have a button that, when clicked, will split the original div into two equal parts, each with its own random background color. With each subs ...

Splitting a row into four columns that will appear consistent on mobile devices

Is it possible to create a row with 4 columns in Angular 6, but have it display as 2 rows with 2 columns each on mobile devices? <div class="row" id="info" *ngIf="this.details"> <div class="col-md-12 mb-3" id="heading"> <h3>Meeting ...

Error: Unable to locate module 'react-bootstrap/Offcanvas'

What steps should I take to address this problem? I've successfully installed Bootstrap and React-Bootstrap, but the issue persists. ...

Adjusting Chart.js line graph alignment to the left

I'm curious about why my chart is not aligned to the left and how I can fix this issue. Here is the code snippet I am working with: var data = { labels: ["ID"] , datasets: [ { label: "Sensor 1" , data: [{ ...

CSS does not have the capability to style child elements

Having trouble changing the text for child elements when applying CSS classes to parent elements. Is there a specific reason why this is happening? Take a look at my current code: <Box //not affecting all child elements ...

When you click on the collapsible header background, the content collapses, but the main icon does not update

I am currently using collapsible content from Bootstrap and I am encountering an issue with the icon not changing when I click on the collapsible-header background. Here is a visual representation of the problem: 1st part (not collapsed) 2nd part (After ...