Vinod Gubbala Vinod Gubbala - 3 months ago 9
CSS Question

Getting table structure with div with grouped divs

I want a tabular data which is in groups.
Wanted all cells of equal width. Please refer code below.



.details {
display: table;
width: 100%;
}
.row {
display: table-row;
}
.cell1, .cell2, .cell3 {
width: 100%;
display: table-cell;
border: 1px solid gray;

}
.groups {
border: 1px solid red;
}

.group-name {
font-weight: bold;
}


<div class="details">
<div class="groups">
<div class="group-name">
one
</div>
<div class="list">
<div class="row">
<div class="cell1">
cell1
</div>
<div class="cell2">
cell2
</div>
<div class="cell3">
cell3
</div>
</div>
<div class="row">
<div class="cell1">
cell1
</div>
<div class="cell2">
cell2
</div>
<div class="cell3">
cell3
</div>
</div>
</div>
</div>
<div class="groups">
<div class="group-name">
two
</div>
<div class="list">
<div class="row">
<div class="cell1">
cell1
</div>
<div class="cell2">
cell2 Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div class="cell3">
cell3
</div>
</div>
<div class="row">
<div class="cell1">
cell1
</div>
<div class="cell2">
cell2 Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div class="cell3">
cell3 some big Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
</div>
</div>
</div>
</div>




Answer

Add flex for equal size.

 .details {
      display: table;
      width: 100%;
  }
  .row {
      display: table-row;
      display:flex;
  }
  .cell1{
       width: 30%;
       display: table-cell;
       border: 1px solid gray;
      flex: 1;
  
  padding: 1em;


  }
 .cell2 {
       width: 30%;
       display: table-cell;
       border: 1px solid gray;
        flex: 1; 
  
  padding: 1em;
 

  }
 .cell3 {
       width: 30%;
       display: table-cell;
       border: 1px solid gray;
       flex: 1; 
        padding: 1em;


  }
  .groups {
       border: 1px solid red;
  }

  .group-name {
       font-weight: bold;
  }
<div class="details">
         <div class="groups">
              <div class="group-name">
                         one
              </div>
              <div class="list">
                 <div class="row">
                       <div class="cell1">
                            cell1
                       </div>
                       <div class="cell2">
                            cell2
                       </div>
                       <div class="cell3">
                            cell3
                       </div>
                  </div>
                  <div class="row">
                       <div class="cell1">
                            cell1
                       </div>
                       <div class="cell2">
                            cell2
                       </div>
                       <div class="cell3">
                            cell3
                       </div>
                  </div>
              </div>
         </div>
         <div class="groups">
              <div class="group-name">
                         two
              </div>
              <div class="list">
                 <div class="row">
                       <div class="cell1">
                            cell1
                       </div>
                       <div class="cell2">
                            cell2 Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
                       </div>
                       <div class="cell3">
                            cell3
                       </div>
                  </div>
                  <div class="row">
                       <div class="cell1">
                            cell1 
                       </div>
                       <div class="cell2">
                            cell2 Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
                       </div>
                       <div class="cell3">
                            cell3 some big Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
                       </div>
                  </div>
              </div>
         </div>
    </div>