cari

Rumah  >  Soal Jawab  >  teks badan

Reka bentuk jadual HTML berdasarkan imej yang disediakan

Saya perlu membuat jadual html berdasarkan struktur jadual dalam gambar di atas. Dah cuba macam-macam cara tapi tak boleh.

Tolong bantu saya membuat jadual Html.

P粉536909186P粉536909186485 hari yang lalu464

membalas semua(1)saya akan balas

  • P粉148782096

    P粉1487820962023-09-15 19:08:55

    Di sini, saya menggunakan colspan 使其占据多个单元格的宽度,然后在单元格上使用 rowspan pada sel pengepala untuk menjadikannya mengembang secara menegak merentas berbilang baris.

    Ini membolehkan 90% gambar anda dipaparkan. Teks menegak/berputar mungkin, tetapi bukan tentang persoalan ini, jadi saya tidak melakukan bahagian itu.

    table{
      border-collapse: collapse;
    }
    td,th {
      padding: 3px;
      border: 1px solid #333;
    }
    th {
      background: #CCC;
    }
    .blank {
      background: #FFF;
      border: none;
    }
    <table>
      <thead>
        <tr>
          <th colspan="3" class="blank"></th>
          <th colspan="8">Attribute Name 1</th>
        </tr>
      </thead>
      <thead>
        <tr>
          <th colspan="3" class="blank"></th>
          <th colspan="2">Attribute 1 Value 1</th>
          <th colspan="2">Attribute 1 Value 2</th>
          <th colspan="2">Attribute 1 Value 3</th>
          <th colspan="2">Attribute 1 Value 4</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <th rowspan="32" class="vertical-text">Attribute Name</th>
          <th rowspan="4" class="vertical-text">Attribute 2 Value 1</th>
          <th>Price Category 1</th>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <th>Price Category 2</th>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <th>Price Category 3</th>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <th>Price Category 4</th>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <th rowspan="4" class="vertical-text">Attribute 2 Value 2</th>
          <th>Price Category 1</th>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <th>Price Category 2</th>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <th>Price Category 3</th>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <th>Price Category 4</th>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <th rowspan="4" class="vertical-text">Attribute 2 Value 3</th>
          <th>Price Category 1</th>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <th>Price Category 2</th>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <th>Price Category 3</th>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <th>Price Category 4</th>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <th rowspan="4" class="vertical-text">Attribute 2 Value 4</th>
          <th>Price Category 1</th>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <th>Price Category 2</th>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <th>Price Category 3</th>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <th>Price Category 4</th>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
      </tbody>
    </table>

    balas
    0
  • Batalbalas