CSS Tabela Responsiva

CSS Tabela Responsiva 

Adicione um elemento container (como <div>) ao overflow-x:auto redor do elemento <table> para torná-lo responsivo:

Na prática

<!DOCTYPE html>

<html>

<head>

<style>

table {

  border-collapse: collapse;

  width: 100%;

}

 

th, td {

  text-align: left;

  padding: 8px;

}

 

tr:nth-child(even) {background-color: #f2f2f2;}

</style>

</head>

<body>

<h2>Tabela responsiva</h2>

<p>Uma tabela responsiva exibirá uma barra de rolagem horizontal se a tela for muito pequena para exibir o conteúdo completo. Redimensione a janela do navegador para ver o efeito:</p>

<p>Para criar uma tabela responsiva, adicione um elemento container (como div) com overflow-x:auto ao redor do elemento table:</p>

 

<div style="overflow-x: auto;">

  <table>

    <tr>

      <th>Primeiro Nome</th>

      <th>Sobrenome</th>

      <th>Pontos</th>

      <th>Pontos</th>

      <th>pontos</th>

      <th>Pontos</th>

      <th>Pontos</th>

      <th>Pontos</th>

      <th>Pontos</th>

      <th>pontos</th>

      <th>Pontos</th>

      <th>Pontos</th>

    </tr>

    <tr>

      <td>José</td>

      <td>Maria</td>

      <td>50</td>

      <td>50</td>

      <td>50</td>

      <td>50</td>

      <td>50</td>

      <td>50</td>

      <td>50</td>

      <td>50</td>

      <td>50</td>

      <td>50</td>

    </tr>

    <tr>

      <td>João</td>

      <td>Rufino</td>

      <td>94</td>

      <td>94</td>

      <td>94</td>

      <td>94</td>

      <td>94</td>

      <td>94</td>

      <td>94</td>

      <td>94</td>

      <td>94</td>

      <td>94</td>

    </tr>

    <tr>

      <td>José</td>

      <td>Silva</td>

      <td>67</td>

      <td>67</td>

      <td>67</td>

      <td>67</td>

      <td>67</td>

      <td>67</td>

      <td>67</td>

      <td>67</td>

      <td>67</td>

      <td>67</td>

    </tr>

  </table>

</div>

</body>

</html>