表/ TD边框不会显示在echo td上

表/ TD边框不会显示在echo td上

问题描述:

I'm echoing a table from mySql. The TD border is not showing up no matter how I input the code. The thead border is showing up just fine.

This is what I have.

// Loop to show results
while ($row = mysqli_fetch_assoc($result)) {

  echo "<tr>";
  echo "<td style=text-align:center>".$row['ETF'].
  "</td>";
  echo "<td style=text-align:center>".$row['ETF NAME'].
  "</td>";
  echo "<td style=text-align:center>".$row['1 YR Direction %'].
  "</td>";
  echo "<td style=text-align:center>".$row['Holding Name'].
  "</td>";
  echo "<td style=text-align:center>".$row['Industry'].
  "</td>";
  echo "<td style=text-align:center>".$row['Percent Holdings'].
  "</td>";

  "</tr>";
}

echo "</table>";
  <style type="text/css">thead,
th {
  font-weight: bold;
  background-color: #992c29;
  color: #f7f4f4;
  border: 2px solid black;
  tr,
  td {
    border: 2px solid black;
  }
  </style>

</div>

You have not closed your th selector, so the styles directly below it are considering invalid syntax, and will never execute.

Closing your th selector by adding in the missing curly brace (}) will resolve your issue:

th {
  font-weight: bold;
  background-color: #992c29;
  color: #f7f4f4;
  border: 2px solid black;
}

tr,
td {
  border: 2px solid black;
}

In addition to this, ensure that no other selectors are overriding your styles with higher specificity.

Hope this helps! :)

Close off missing

thead,
th {
  font-weight: bold;
  background-color: #992c29;
  color: #f7f4f4;
  border: 2px solid black;
}
tr,
td {
    border: 2px solid black;
}