Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can display table-row behave like colspan=3

Tags:

css

I need two rows, the first one have 3 columns and the second I need to span all the width just like the td colspan=3 would do

Or display: table-cell; behave like colspan=3

I am using display: table-row; width: 100%;

How can it be done ?

This is my CSS :

<style>
      .boxer {
         display: table;
         border-collapse: collapse;
      }
      .boxer .box-row {
         display: table-row;
      }
      .boxer .box-row-search {
         display: table-row;
         width: 100%;
      }
      .boxer .box {
         display: table-cell;
         text-align: left;
         vertical-align: top;
         border: 1px solid black;
      }
</style>
like image 420
Ângelo Rigo Avatar asked Apr 05 '16 00:04

Ângelo Rigo


People also ask

What does Colspan 3 mean?

These are used to specify the number of rows or columns a cell should span. The rowspan attribute is for rows as well as the colspan attribute is for columns. These attributes have numeric values, for example, colspan=3 will span three columns.

What is Colspan in table?

The colspan attribute defines the number of columns a table cell should span.

How do you create a table with 3 rows and 5 columns in HTML?

You first declare the table with the <table> markup, and then the rows with the <tr> markup. (table row.) Inside each row, you can declare the data containers <td> . (table data).

How do you add Colspan to a table?

The colspan attribute in HTML is used to set the number of columns a cell should span in a table. Use the colspan attribute on the <td> or <th> element.


1 Answers

Using display: table; it cannot be done (cause sadly there's no colspan: 3; or rowspan property in CSS, therefore stylesheet is unable to mimick a real <table> element)

but hey, flex to the rescue!

.row{
  display: flex;
  flex-flow: wrap;
}
.cell{
  width: 25%;
  background:#eee;
}
.colspan2{
  flex: 2;
}
<div class="row">
  <div class="cell">Cell1</div>
  <div class="cell">Cell2</div>
  <div class="cell">Cell3</div>
  <div class="cell">Cell4</div>
  <div class="cell">Cell5</div>
  <div class="cell colspan2">Cell6 Colspan2</div>
  <div class="cell">Cell7</div>
</div>
like image 175
Roko C. Buljan Avatar answered Sep 22 '22 04:09

Roko C. Buljan