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

Event follows activation of trigger click

I've already gone through this post on Stack Overflow about triggering an action after a click event, but none of the solutions I've tried so far have worked. Let's say I have a menu on my webpage like this: <ul class="nav nav-tabs"&g ...

Adding an image to an HTML <span> element using the class attribute "

I need help adding an image to my HTML code. For example, how can I specify which image should be displayed in place of the placeholders? Thank you for your assistance! ...

Tips for aligning numbers in a monospaced ordered list

Is there a way to align the numbers in a numbered list within a table using monospace font so that they are at the same level as bullets on a bullet list? Simplest example: ol { font-family: monospace; } ul, ol { margin-top: 10px; margin-bottom: ...

"Struggling with vertical alignment in my scenario, any tips on how to achieve

I'm trying to vertically align my texts while ensuring that the green background div covers the entire height of the red color div. Right now, the green div only covers 90% of the red div and I'm not sure why. Can someone please explain what&apos ...

Encountered error: "Node.js and socket.io: Address already in use"

Experimenting with chat using Node.js and socket.io Currently, I am running Ubuntu 12.04 as a user and have a folder "pp" on my desktop. In this folder, I have placed a server file named server.js. Below is the client code: $(document).ready(function() ...

Add a unique shape to the CSS clip property

Recently, I've been delving into the clip property of CSS and its ability to apply a rectangle or square object. Despite my research efforts, I haven't come across a clear answer to my question. Can you actually use a customized shape with the c ...

Angular Material Sidenav fails to cover the entire screen while scrolling

https://i.stack.imgur.com/32kfE.png When scrolling, the Sidenav is not expanding to take up 100% of the screen and it continues to scroll along with the page content. <div layout="column"> <section layout="row" flex> <!-- siden ...

Creating a button with multiple background gradients using CSS

When working on a button element that already boasts a gradient effect, my aim was to integrate a small play image directly in the center. However, achieving this without compromising the current layout and ensuring compatibility across various browsers pr ...

Menu Design Inspired by Amazon Using jQuery

Can someone please assist me in locating a jQuery Amazon-style menu example? I would like to implement something similar and am hoping to avoid having to write it from scratch. Thank you! ...

encountering difficulty incorporating menu.php within main.php

I'm currently working on integrating the menu.php file into my main.php. Here is what I have accomplished so far: Main.php <html> <body> <?php include("menu.php"); ?> <p>This is an example to demonstrate how ...

Utilizing offsets/push in the correct manner

I have been developing a Bootstrap website and I wanted to get some feedback on my current code structure. The design is coming along nicely, but I am unsure if this aligns with best practices? <div class="container-fluid"> <div class="row"> ...

Change the background color of the selectInput component in Shiny to fit your

Take a look at this sample shiny app: library(shiny) ui <- fluidPage(tags$head(includeCSS("www/mycss.css")), selectInput("foo", "Choose", width = '20%', multiple = F, selected = "red1", choices = list(red = c ...

How can I use an HTML button to activate a function that inserts text into a read-only text-box?

Trying to write a simple piece of HTML code that finds the number greater than or equal to the first initial amount that wholly divides the second given amount. The code attempts to divide the numbers, and if it fails, increments the first number by 1 and ...

Adjust the column count based on the screen size, Susy suggested

When using the Compass/Sass plugin Susy, you typically set the number of columns in the _base.scss file. I prefer to have 12 columns for a desktop view, but this may be too many columns for a mobile display. Is there a method to alter the number of column ...

Hover effect transition malfunctioning

I've been attempting to incorporate a hover image effect on my website. I included the script in the link below. However, I'm struggling to achieve a smooth fade transition and a 2-second delay on the hover image. Can someone please assist me wit ...

Unable to successfully import an external HTML file that contains a script tag

I am currently experiencing an issue with my index.html <!doctype html> <html lang="en"> <head> <meta charset="utf-8> <title>MyApp</title> <link rel="import" href="./common.html"> </head> <body> ...

What steps should be taken to prevent divs from overlapping a centrally positioned, unchanging div when the browser is resized

Looking to create a layout with two columns, featuring a fixed sidebar on the left and centering the main content area. The goal is for the centered content to remain in place when resized and not move further left than where it touches the nav bar (left: ...

Does HTML elements come with a pre-set background color of white or transparency by default?

Feeling a bit confused about a straightforward issue. Can someone clarify for me - What is the original background color of HTML elements? Is it white by default or transparent? ...

Guide on extracting HTML content from JSON and displaying it in a UIWebView (utilizing Swift 3.0)

Can anyone guide me on how to use JSON2HTML to parse HTML data from JSON and display it in an UIWebView using Swift 3.0? Your help is much appreciated! This is what I have attempted so far: let jsfile1 = try!String(contentsOfFile: Bundle.main.path(forRes ...

Using jQuery to create clickable URLs within a rollover div

I am looking to have the div appear on a mouse over effect in the following code. Is there a way for me to input a url based on the data that is passed to it? Anchorage: ["Anchorage", "(555)555-5555"], (This represents the data being posted) AtlanticCit ...