0

I want to extend the first column (Service Request) til the second column (blank) so it should be display like 1 column 2 rows. I have this css and html on jsfiddle.

Hope you can help me with this.

<div class="Table">
<div class="Title">
    <p>This is a Table</p>
</div>
<div class="Heading">
    <div>
    </div>
    <div class="Cell">
        <p>Case Status</p>
    </div>
    <div class="Cell">
        <p>Count</p>
    </div>
      <div class="Cell">
        <p>Case Age</p>
    </div>
     <div class="Cell">
        <p>Case Affected HC</p>
    </div>
     <div class="Cell">
        <p>Schedule HC</p>
    </div>
     <div class="Cell">
        <p>% Affected</p>
    </div>
</div>
<div class="Row">
    <div class="Cell merged">
        Service Request
    </div>
    <div class="Cell">
        <p>Open</p>
    </div>
    <div class="Cell">
        <p></p>
    </div>
    <div class="Cell">
        <p></p>
    </div>
     <div class="Cell">
        <p></p>
    </div>
    <div class="Cell">
        <p></p>
    </div>
    <div class="Cell">
        <p></p>
    </div>
</div>
<div class="Row">
    <div class="Cell">            
    </div>
    <div class="Cell">
        <p>Closed</p>
    </div>
    <div class="Cell">
        <p>Row 2 Column 3</p>
    </div>
</div>

div table

The output should be like this one Output

Thanks in advance guys.

  • 2
    so why exactly are you not using a table instead? – Nidhin Joseph Nov 05 '19 at 08:05
  • Possible duplicate of [Colspan/Rowspan for elements whose display is set to table-cell](https://stackoverflow.com/questions/9277661/colspan-rowspan-for-elements-whose-display-is-set-to-table-cell) – Constantin Groß Nov 05 '19 at 08:06
  • @NidhinJoseph sorry bro, but the requirement is to use div instead of table. – Hudas Iskaryote Nov 05 '19 at 08:26
  • Strictly speaking this is not possible with divs. If the rows are the same height you may style it with CSS. Maybe use something like grid or position: absolute. If the height of the rows is dynamic, you might have to use JS. Easiest is to use real tables to achieve this effect. – J.T. Houtenbos Nov 05 '19 at 08:57
  • 1
    looks like a typical table HTML use. there is no colspa/rowspan in CSS, but you have display:grid that allows children to span through the row or column grid.. You should use a table when it makes sens, Does your HTML without any style is readable ? https://jsfiddle.net/oqjkravs/ – G-Cyrillus Nov 05 '19 at 09:44
  • CSS-Grid would be the ideal "alternative" option but the HTML structure would need to change. I think this might be more complicated though and require `subgrid`. A table here is the BEST option...and more semantic. – Paulie_D Nov 05 '19 at 11:38

1 Answers1

0

Use a table (it's easier for a thing like that) and then use a rowspan

table.blueTable {
  border: 1px solid #1C6EA4;
  background-color: #EEEEEE;
  width: 100%;
  text-align: left;
  border-collapse: collapse;
}
table.blueTable td, table.blueTable th {
  border: 1px solid #AAAAAA;
  padding: 3px 2px;
}
table.blueTable tbody td {
  font-size: 13px;
}
table.blueTable tr:nth-child(even) {
  background: #D0E4F5;
}
table.blueTable thead {
  background: #1C6EA4;
  background: -moz-linear-gradient(top, #5592bb 0%, #327cad 66%, #1C6EA4 100%);
  background: -webkit-linear-gradient(top, #5592bb 0%, #327cad 66%, #1C6EA4 100%);
  background: linear-gradient(to bottom, #5592bb 0%, #327cad 66%, #1C6EA4 100%);
  border-bottom: 2px solid #444444;
}
table.blueTable thead th {
  font-size: 15px;
  font-weight: bold;
  color: #FFFFFF;
  border-left: 2px solid #D0E4F5;
}
table.blueTable thead th:first-child {
  border-left: none;
}

table.blueTable tfoot {
  font-size: 14px;
  font-weight: bold;
  color: #FFFFFF;
  background: #D0E4F5;
  background: -moz-linear-gradient(top, #dcebf7 0%, #d4e6f6 66%, #D0E4F5 100%);
  background: -webkit-linear-gradient(top, #dcebf7 0%, #d4e6f6 66%, #D0E4F5 100%);
  background: linear-gradient(to bottom, #dcebf7 0%, #d4e6f6 66%, #D0E4F5 100%);
  border-top: 2px solid #444444;
}
table.blueTable tfoot td {
  font-size: 14px;
}
table.blueTable tfoot .links {
  text-align: right;
}
table.blueTable tfoot .links a{
  display: inline-block;
  background: #1C6EA4;
  color: #FFFFFF;
  padding: 2px 8px;
  border-radius: 5px;
}
<table class="blueTable">
  <thead>
  <tr>
  <th style="background:white"></th>
  <th>head2</th>
  <th>head3</th>
  <th>head4</th>
  </tr>
  </thead>
  <tfoot>
  <tr>
  <td colspan="4">
  <div class="links"><a href="#">&laquo;</a> <a class="active" href="#">1</a> <a href="#">2</a> <a href="#">3</a> <a href="#">4</a> <a href="#">&raquo;</a></div>
  </td>
  </tr>
  </tfoot>
  <tbody>
  <tr>
  <td rowspan="2">cell1_1</td>
  <td>cell2_1</td>
  <td>cell3_1</td>
  <td>cell4_1</td>
  </tr>
  <tr>

  <td>cell2_2</td>
  <td>cell3_2</td>
  <td>cell4_2</td>
  </tr>
  <tr>
  <td>cell1_3</td>
  <td>cell2_3</td>
  <td>cell3_3</td>
  <td>cell4_3</td>
  </tr>
  <tr>
  <td>cell1_4</td>
  <td>cell2_4</td>
  <td>cell3_4</td>
  <td>cell4_4</td>
  </tr>
  </tbody>
</table>
alesssz
  • 384
  • 4
  • 18