15

左の列に2つのマージされた行があり、右の列には何もないという効果を達成したいだけです。このレイアウトを実現するにはどうすればよいですか?

HTMLテーブルは次のようになります-

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

編集:Divを使用してこれを達成したい。各 div 要素にユーザー コントロールを配置します。Div3 は Div2 の下で開始するが、Div1 の下では開始しないことが重要です。

【初投稿なので画像載せれません】

ありがとう。

4

2 に答える 2

8

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>

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

于 2012-11-27T14:06:09.553 に答える