What is the best method to insert multiple rows of the same height into a table cell in

My datatable is causing me trouble as I try to add more rows in the td after the Name column. The rows are not aligning properly, and I need a solution.

I want these new rows to be aligned with each other, but the number of rows may vary based on user input.

I've attempted to use rowspan, but it's proving to be ineffective. My design is just a sample, so feel free to suggest your own ideas. However, my current solution is not achieving the desired alignment.

table, td, tr {
  border: 1px solid black;
}

table {
border-collapse: collapse;
}
<table class="table table-bordered table-striped table-hover datatable datatable-Room" style="width: 100%">
  <thead>
    <tr>
      <th>Name</th>
      <th>Plan Name</th>
      <th>Plan Period</th>
      <th>Amount</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>
        <a href="#">John</a>
      </td>
      
      <td>
        <div>Some Plan</div>
        
        <hr>
        
        <div>Some Plan</div>
      </td>
      <td class="p-0">

        <div>Aug 02, 2021 - Aug 20, 2021</div>
        <div>Weekly</div>
        
        <hr>
        
        <div>Aug 10, 2021 - Sep 20, 2021</div>
        <div>Monthly</div>

      </td>
      <td class="p-0">
        <div>$30</div>
        
        <hr>
        
        <div>$45</div>
      </td>

    </tr>
    
    <tr>
      <td>
        <a href="#">John</a>
      </td>
      
      <td>
        <div></div>
        
        <hr>
        
        <div>Some Plan</div>
      </td>
      <td class="p-0">

        <div>Aug 02, 2021 - Aug 20, 2021</div>
        <div>Weekly</div>
        
        <hr>
        
        <div>Aug 10, 2021 - Sep 20, 2021</div>
        <div>Monthly</div>

      </td>
      <td class="p-0">
        <div>$30</div>
        
        <hr>
        
        <div>$45</div>
      </td>

    </tr>
  </tbody>
</table>

Answer №1

Is this the desired outcome?

table, td, tr {
  border: 1px solid black;
}

table {
  border-collapse: collapse;
}
<table class="table table-bordered table-striped table-hover datatable datatable-Room" style="width: 100%">
  <thead>
    <tr>
      <th>Name</th>
      <th>Plan Name</th>
      <th>Plan Period</th>
      <th>Amount</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td rowspan="2"><a href="#">John</a></td>
      <td>Some Plan</td>
      <td class="p-0">
        <div>Aug 02, 2021 - Aug 20, 2021</div>
        <div>Weekly</div>
      </td>
      <td class="p-0">
        <div>$30</div>
      </td>
    </tr>

    <tr>
      <td>Some Plan</td>
      <td class="p-0">
        <div>Aug 10, 2021 - Sep 20, 2021</div>
        <div>Monthly</div>
      </td>
      <td class="p-0">
        <div>$45</div>
      </td>
    </tr>

    <tr>
      <td rowspan="2"><a href="#">John</a></td>
      <td></td>
      <td class="p-0">
        <div>Aug 02, 2021 - Aug 20, 2021</div>
        <div>Weekly</div>
      </td>
      <td class="p-0">
        <div>$30</div>
      </td>
    </tr>

    <tr>
      <td>Some Plan</td>
      <td class="p-0">
        <div>Aug 10, 2021 - Sep 20, 2021</div>
        <div>Monthly</div>
      </td>
      <td class="p-0">
        <div>$45</div>
      </td>
    </tr>
  </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

What advantages does including @charset "ISO-8859-15"; at the top of a CSS file provide?

Why would adding @charset "ISO-8859-15"; or @charset "utf-8"; at the beginning of a CSS file be advantageous? ...

"Optimizing Background Images with IE 8 Stretch Cover in Bootstrap

Page Broken I've searched all over Stack Overflow for a solution to resolve this background image issue. I'm using Bootstrap for the boxes and removed any margins. The problem arises when setting the background as cover; in IE8, it doesn't ...

Utilizing pop-up alerts and AJAX requests in jQuery forms

I am looking to enhance my website by creating a form using PHP and jQuery. Currently, the form is placed in the footer of my website. However, I want to display the form results in a popup within the main section of the website without requiring a page ...

Troubleshooting techniques for resolving CSS issues with the video.js package in ReactJS

When using video.js in react to build a video player, I encountered an issue with the npm package not providing its inbuilt CSS. How can I add the inbuilt CSS of video.js? Instead of the control bar, I am getting something different than what is shown in t ...

Carousel-Owl, glide through two items simultaneously

I am currently in the process of developing a slider using the beta version of Owl-Carousel 2, but I am encountering several issues. My goal is to configure the owlCarousel to function as follows: It should scroll through 2 items at a time while displayin ...

Font that has been downloaded is not showing up on the HTML document

I recently downloaded a new font and ensured the file location is correct, but for some reason it's not working: <style> @font-face { font-family:"myfont"; src: url('fonts/Helvetica85Heavy_22449.ttf'); } h1 { font-family: ...

AngularJS: resolving route dependencies

I have a variable $scope.question that contains all the questions for the page. My goal is to loop through the questions page by page. To achieve this, I created a function called questionsCtrl and I am calling this function in the config while setting up ...

Extracting the URL of the @font-face declaration in CSS with the use of JavaScript

Currently, my CSS file contains numerous @font-face tags. Each tag specifies a unique font-family and src URL. @font-face{ font-family: Garamond; src: url('ePrintFonts/pcl_91545.ttf'); } @font-face{ font-family: C ...

Unifying flex and position:fixed

I'm having difficulties when it comes to displaying a modal dialog with a fixed position within a flex layout. The header and footer of the dialog need to be set in height, while the content section should have overflow with scrollbars. I chose the fl ...

Having trouble with the width of the Material-UI drawer feature

Encountering an issue with the material-ui drawer. I adjusted the width of the drawer container, which led to a problem where the drawer remains slightly inside the page and visible without clicking the button. It seems to be related to the transform attri ...

scraping information using xpath from the subsequent page

I've been attempting to extract data from a webpage located at , focusing on fund number 26. While I have no trouble retrieving information from the first page (funds number 1-25), I'm facing difficulties with scraping anything from the second p ...

Utilizing CSS for a specific row within the grid-template-areas placement

Hey there, I'm diving into the world of coding and taking on a new project as a beginner. My goal is to recreate Google's Advanced Search page from scratch. Right now, I'm focusing on creating the header section using the power of display: g ...

Updating values using jQuery when tags in a single table row are changed

In my current setup, I have a table structured as follows: <table> <tbody> <tr> <td> <input type="text" class="identifier" /> </td> <td class="name"> Some value < ...

How can I position an element to the bottom right using CSS?

Is there a way to position this element to the bottom right corner? HTML <div class="info player"> <div id="job" style="display:none;"><span>Jobname</span></div> <div i ...

The feature of Switch css does not appear to function properly when used in conjunction with input type

Why does the switch button not work with the input type radio but works with a checkbox button? How can I maintain the radio input and solve this issue? @charset "utf-8"; /* CSS Document */ /* ---------- GENERAL ---------- */ body { background: #4a4a4 ...

illuminate selected row in datatable using a jquery plugin

My data is displayed using the jQuery plugin DataTable, and everything appears to be working well. I am retrieving my data from PHP using AJAX. However, I encountered an issue when trying to highlight the row that was hovered over while navigating around ...

Unable to select dropdown button in Python while using Selenium

My goal is to click on the "Project" element in order to display a dropdown list (as shown in the image below). When using the selenium library in Python, I encountered the following error: could not be scrolled into view This error was triggered by code ...

Get rid of the arrow that is displayed when using the `time` input type in HTML5

Recently, I encountered an issue with the default HTML5 code snippet. My custom background looked perfect except for a pesky black arrow appearing on the right side. In this image, you can see the problematic black arrow that needs to be removed. I attemp ...

Import the information into a td tag's data-label property

I have implemented a responsive table design that collapses for smaller screens and displays the table header before each cell. body { font-family: "Open Sans", sans-serif; line-height: 1.25; } table { border: 1px solid #ccc; border-collapse: co ...

Navigating through a diagonal path

Struggling to craft a diagonal navigation system similar to the images below. Despite its seemingly simplicity, I'm stuck investing too much time in figuring it out. My goal is for the menu container to smoothly reveal from right to left when clicking ...