Posso avere un colpo di intestazione da tavolo HTML su due colonne da tavola?Mi piace unire e il centro in Excel?

StackOverflow https://stackoverflow.com/questions/8996466

Domanda

Voglio avere un'intestazione da tavolo essere centrata su due colonne da tavola fianco a fianco.È possibile?

È stato utile?

Soluzione

<th colspan="2">. This .</th>

Per estrapolare un po '...

<table>
  <thead>
    <tr>
      <th>Single Column</th>
      <th colspan="2">Double Column</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Column One</td>
      <td>Column Two</td>
      <td>Column Three</td>
    </tr>
  </tbody>
</table>
.

che dovrebbe darti abbastanza da lavorare da.

Altri suggerimenti

Se hai solo 2 colonne, suggerirei di utilizzare <caption>.Altrimenti, utilizzare Colspan come suggerito in altre risposte.

<table>
  <caption>This will span all columns.</caption>
  <tr><td>column one</td><td>column two</td></tr>
</table>
.

certo.Si prega di fare riferimento a Questa pagina .Stai cercando un attributo chiamato colspan per le celle delle intestazioni da tavolo.

Possiamo farlo in modo migliore.

<table border="1"> 
  <tr>
    <th colspan="1" scope="colgroup">Test Heading</th>
    <th colspan="3" scope="colgroup">Mars</th>
    <th colspan="3" scope="colgroup">Venus</th>
    <th colspan="3" scope="colgroup">Test</th>
  </tr>
  <tr>
    <th rowspan="2"></th>
    <th scope="col">Produced</th>
    <th scope="col">Sold</th>
    <th scope="col">Sold</th>
    <th scope="col">Produced</th>
    <th scope="col">Sold</th>
    <th scope="col">Sold</th>
    <th scope="col">Test 1</th>
    <th scope="col">Test 2</th>
    <th scope="col">Test 3</th>
  </tr>
</table>
.

Visita tabella ref da w3.org se vuoi saperne di più.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top