css 表不起作用


Css Table doesn't work

我想通过CSS修改我的表格,但它不起作用,唯一不起作用的CSS部分是表格。CSS的其余部分可以正常工作。

PHP代码:

   <table style="width:100%">
           <tr>
            <td>Nif</td>
            <td>Nom</td>        
            <td>Cognoms</td>
            <td>Data</td>
            <td>Provincia</td>
           </tr>
   <?php 
      while ($fila = mysqli_fetch_row($resultado2)) {
        $Nif =$fila[0];
        $Nombre=$fila[1];
        $Cognoms=$fila[2];
        $Fecha=$fila[3];
        $Provincia=$fila[4];
       echo"<tr>";
       echo"<td>$Nif</td>";
       echo"<td>$Nombre</td>";      
       echo"<td> $Cognoms</td>";
       echo"<td> $Fecha</td>";
       echo"<td>$Provincia</td>";
       echo"</tr>";
     echo" </table>";
     }
     mysqli_close($con);
     ?>

CSS 的一部分:

input#boton{
    color:white;
    font-size:2em;
    background-color:#00BFFF;
    height:0.8cm;
    border:2px;
    width:80%;
    margin-top:1%;
     margin-left:10%;
    -webkit-border-radius:5px;
        -ms-border-radius:5px;
        -moz-border-radius:5px;
}
input#boton:hover{
    background-color:#2EFE2E;
}
table, th, td {
    border: 2px solid black;
    color: blue;
    width: 50%;
    font-size: 150%;
    text-align:center;
    background-color:yellow;
}

任何帮助将不胜感激。

对于每一行,您打印echo" </table>"; 您应该将其放在 while 循环的末尾。

您的 PHP 代码中有错误。 不得在每行中打印表。

while(){}