Maison  >  Questions et réponses  >  le corps du texte

Existe-t-il d'autres solutions au problème de colspan="1.5" qui ne fonctionne pas ?

C'est la table dont j'ai besoin Je peux facilement obtenir les première et deuxième rangées, mais lorsque j'essaie de faire en sorte que la troisième rangée soit bonne, je casse la deuxième rangée.

J'ai essayé d'utiliser l'attribut width et colspan mais rien n'a fonctionné.

<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 Il y a quelques jours420

répondre à tous(1)je répondrai

  • P粉262073176

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

    <table> 默认情况下会符合其内容,因此不需要每列的宽度相等。因此,通过将 table-layout:fixed 分配给 <table> 来手动分配相等的列宽度,然后通过将每个宽度分配给第一个 < 的 <thead> 中的 <th> 来为每列分配相等的宽度。 tr> 或缺少为第一个 <tr><td> 分配宽度(当然 tdth comme sélecteur fonctionne également), voir exemple ci-dessous.

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

    répondre
    0
  • Annulerrépondre