Heim  >  Fragen und Antworten  >  Hauptteil

Gibt es andere Lösungen für das Problem, dass colspan="1.5" nicht funktioniert?

Das ist der Tisch, den ich brauche Ich schaffe es problemlos, die erste und zweite Reihe zu bekommen, aber wenn ich versuche, die dritte Reihe gut zu machen, zerbreche ich die zweite Reihe.

Ich habe versucht, das Attribut width und colspan zu verwenden, aber nichts hat funktioniert.

<table border="1px" width="100%">
        <tr>
            <td colspan="6">Cell 1</td>
        </tr>
        <tr >
            <td colspan="3">Cell 2</td> 
            <td colspan="3" >Cell 3</td>
        </tr>
        <tr>
            <td colspan="2">Cell 4</td> 
            <td colspan="2">Cell 5</td>            
            <td colspan="2">Cell 6</td> 
        </tr>
    </table>

P粉368878176P粉368878176194 Tage vor418

Antworte allen(1)Ich werde antworten

  • P粉262073176

    P粉2620731762024-03-31 00:42:12

    <table> 默认情况下会符合其内容,因此不需要每列的宽度相等。因此,通过将 table-layout:fixed 分配给 <table> 来手动分配相等的列宽度,然后通过将每个宽度分配给第一个 < 的 <thead> 中的 <th> 来为每列分配相等的宽度。 tr> 或缺少为第一个 <tr><td> 分配宽度(当然 tdth 作为选择器也可以),请参见下面的示例。

    table {
      table-layout: fixed;
    }
    
    td {
      width: 16.5%;
      text-align: center;
    }
    I
    II III
    IV V VI

    Antwort
    0
  • StornierenAntwort