Adjust the size and alignment of columns within a Bootstrap table by incorporating a nested table

My goal is to adjust the size and alignment of the header components within the thead section of an HTML table to match those of a nested table.

The main table handles the alternating row colors, while the nested table enables me to organize the fields across multiple rows.

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

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5a3835352e292e283b2a1a6f746b746a">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">

<table class="table table-striped table-sm">
  <thead>
    <tr>
      <th>Project</th>
      <th>Date</th>
      <th>Starting</th>
      <th>Ending</th>
      <th>+/-</th>
      <th>Duration</th>
      <th>Rate</th>
      <th>Total</th>
      <th>Action</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td colspan="9">
        <form method="post" action="/edit">
          <table>
            <tbody>
              <tr>
                <td><input type="text" class="form-control form-control-sm" placeholder="Project"></td>
                <td><input type="date" class="form-control form-control-sm"></td>
                <td><input type="time" class="form-control form-control-sm"></td>
                <td><input type="time" class="form-control form-control-sm"></td>
                <td><input type="number" step="0.25" class="form-control form-control-sm"></td>
                <td><input type="number" class="form-control form-control-sm" disabled=""></td>
                <td>
                  <div class="input-group">
                    <span class="input-group-text"><i class="fas fa-dollar-sign"></i></span>
                    <input type="number" class="form-control form-control-sm">
                  </div>
                </td>
                <td>
                  <div class="input-group">
                    <span class="input-group-text"><i class="fas fa-dollar-sign"></i></span>
                    <input disabled="" type="number" class="form-control form-control-sm">
                  </div>
                </td>
                <td>
                  <button type="submit" class="btn btn-outline-primary btn-sm">Save</button>
                  <a href="/delete" role="button" class="btn btn-outline-danger btn-sm">Delete</a>
                </td>
              </tr>
              <tr>
                <td colspan="8">
                  <input type="text" class="form-control form-control-sm" placeholder="Notes">
                </td>
              </tr>
            </tbody>
          </table>
        </form>
      </td>
    </tr>
  </tbody>
</table>

I attempted to apply column classes (class="col-sm-4") to both the header and detail rows, but it didn't yield satisfactory results.

View the Fiddle.

Answer №1

It appears that a simple table with some customized CSS could meet all your requirements without the need to struggle with customizing the library's features.

If you're looking to make the forms functional, refer to this helpful response. Essentially, you can set up a form element for each input row and use the form attribute on the inputs to link them correctly.

Remember, for accessibility reasons, every input field should have a corresponding label, which can be hidden from view while still being crucial for usability.

.table-striped-pairs tr:nth-child(4n-2) td,
.table-striped-pairs tr:nth-child(4n-3) td {
  background-color: #f2f2f2;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0e6c61617a7d7a7c6f7e4e3b203f203e">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">

<table class="table table-sm table-striped-pairs">
  <thead>
    <tr>
      <th>Project</th>
      <th>Date</th>
      <th>Starting</th>
      <th>Ending</th>
      <th>+/-</th>
      <th>Duration</th>
      <th>Rate</th>
      <th>Total</th>
      <th>Action</th>
    </tr>
  </thead>

  <tbody>
    <!-- Input fields and controls go here -->
  </tbody>
</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

"Provide information, then open a new webpage by clicking on a button. Perform various actions with the form by using type

Is there a way to quickly submit form entries to my database and then automatically redirect to a new page? My current situation requires that submitted information is stored in the DB before directing users to a thank you page, all in one seamless click! ...

Uploading Multiple Files with Base64 Encoding in PHP

I am looking for a way to store images in a database and retrieve them using base64 encoding/decoding. Can anyone guide me on how to achieve this? Here is the HTML code: <form method="POST" action="add_script.php" enctype="multipart/form-data"> ...

Obtain the script's event feedback from the WebView and transfer it to React Native

My HTML script is used to display a module, but I encountered an issue with the eventHandler not responding. How can I ensure that the eventHandler in Web View triggers responses? I am not receiving any logs for the onSuccess, onError, or onClose methods w ...

Creating a drop-down menu that aligns perfectly under the bar in Material-UI: What you need to know

While working with Material-UI, I encountered a problem with my drop-down menu. Every time I click on it, it covers the bar instead of appearing below it (see image links below). https://i.stack.imgur.com/1Y8CL.jpg https://i.stack.imgur.com/emf87.jpg Is ...

Print media not affected by Bootstrap styling

Below is the code I am using to display a table within my application: var elementToPrint = this.mainTable.get(0); newWin = window.open(""); newWin.document.write('<html><head><title>' + elementToP ...

Managing the Response from Google Geocode API in a Vue JS Component

I am facing an interesting challenge. I have a scenario where users can choose between two options - using their current location or entering a zip code. When a user inputs a zip code, I need to make a call to the Google geocode API to retrieve the central ...

Personalizing the fileTemplate selection in FineUploader

My English is not the best, so apologies in advance. I'm struggling to customize the FineUploader FileTemplate option. I don't want to use fineUploaderBasic; I want total customization. Initially, I managed to hide the file name and size after a ...

Embellishing Bootstrap with a splash of color class

After exploring Bootstrap, I've noticed the limited number of "color classes" available (primary, success, danger etc.). Is there a simple way to add more classes similar to those? For instance, the "primary" class can be used across various elements ...

Incorporate JavaScript code into an Angular UI-Router view

I can't seem to find an answer to this question anywhere, so I'm hoping someone here can help me out. In my AngularJS app, I am using ui-router to load multiple views into the same <ui-view> element. I am trying to implement Jquery UI&apos ...

Struggling to center divs in HTML and CSS but running into issues on mobile devices?

I've been facing some serious CSS issues lately! Currently, I have everything set up to center the #Box div, which works perfectly on all devices except for mobile browsers. The problem arises because the screen size of the mobile browser is too narr ...

What is the reason behind the inability of this YouTube instant search script to enable fullscreen mode?

Looking to implement a Youtube instant search on my website, I came across this script that seems ideal for my needs. However, I'm facing an issue where the iframe is not displaying the allowfullscreen property. Can anyone assist with this problem? Th ...

The scrollbar located within a table cell is malfunctioning and unresponsive

In a container with a fixed width of 500px, I have a table that contains a cell with potentially long text. To ensure the long text appears on a single line, I set the white-space: nowrap property. However, this causes the table to adjust its size to accom ...

Create a distinct CSS animation 'origin' declaration for every <g> element

I am using CSS animation to apply a 'wobble' effect to each letter within a word. The letters are represented by SVG groups <g>. However, in the provided example, the wobbling effect becomes more pronounced with each subsequent letter, wher ...

Automating the process of submitting a checkbox

Displayed below is a mix of HTML and JavaScript: <form method = "post" style="display: inline;" name="thisform<?php echo $employee->id; ?>"> <input type="hidden" name="user" value="<?php echo $employee->id; ?&g ...

Limit on the number of rows/entries selected for each query and the maximum

Is it possible to set a limit on data selection in a drop-down list through coding? For example, having 3 selections in one drop-down list, with each selection limited to 20 people choosing from the data. <tr><td><label><font face=&a ...

What is the best way to arrange buttons in a row horizontally?

Desired Output I need help aligning the buttons as shown in the Desired Output image, but when I run the code, the buttons stack vertically, resulting in Output like this. I've included the HTML, CSS, and JS code below. As a beginner in UI design, I ...

Customize the Header Background Color in React Table

I'm working on customizing a re-useable table component using vanilla CSS. I have defined six color variables and want users to be able to select one of them to change the table header background color. However, I am unsure how to make this color choi ...

Exploring the capabilities of HTML5 canvas and integrating it with Selenium using Python

I have been working on testing a web server that is built using HTML5 with a canvas. While examining the source code for the login page, I noticed very minimal content. However, upon inspecting the element in Chrome, I discovered the following snippet: &l ...

Setting a class for a specific date on a jQuery UI calendar using the MultipleDates plugin

I recently encountered an issue with the Multiple Dates picker for jQuery UI date picker. It seems that the developer who created it has not updated it in quite some time, resulting in pre-highlighting dates no longer functioning properly. To address this ...

Combining PHP and MySQL with a join statement

I am trying to calculate the average rating for each store in a directory list using MySQL's AVG function. Whenever someone reviews a store, they assign a rating ranging from 1 to 5. This rating is then inserted into the rating column of the reviews ...