Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS - rowspan like effect

Tags:

css

I simply want to achieve the effect where the left column has two merged rows and the one on right has none. How can I achieve this layout?

The html table will look like -

<table border="1" >
  <tr>
    <td rowspan="2">Div 1</td>
    <td> Div 2 </td>
  </tr>
  <tr>
    <td>Div3</td>
  </tr>
</table>​​​​​​

Edit: I want to acheive this using Div. I would be putting User control in each div element. It is important that Div3 starts below div2 but not below Div1.

[Sorry, this is first post so cannot add image]

Thanks.

like image 861
devSuper Avatar asked Nov 27 '12 13:11

devSuper


1 Answers

CSS

    body {
      margin: 0;
      padding: 50px;
      background-color: #FFFFFF;
      color: #000000;
      font-family: Arial, Helvetica, sans-serif;
    }
    .tablewrapper {
      position: relative;
    }
    .table {
      display: table;
    }
    .row {
      display: table-row;
    }
    .cell {
      display: table-cell;
      border: 1px solid red;
      padding: 1em;
    }
    .cell.empty
    {
      border: none;
      width: 100px;
    }
    .cell.rowspanned {
      position: absolute;
      top: 0;
      bottom: 0;
      width: 100px;
    }

<div class="tablewrapper">
      <div class="table">
        <div class="row">
          <div class="cell">
            Top left
          </div>
          <div class="rowspanned cell">
            Center
          </div>
          <div class="cell">
            Top right
          </div>
        </div>
        <div class="row">
          <div class="cell">
            Bottom left
          </div>
          <div class="empty cell"></div>
          <div class="cell">
            Bottom right
          </div>
        </div>
      </div>
    </div>

Demo: http://www.sitepoint.com/rowspans-colspans-in-css-tables/

like image 189
harikrishnan.n0077 Avatar answered Oct 21 '22 12:10

harikrishnan.n0077