我在这里错过的东西,PHP表格行的风格部分工作!

时间:2009-10-15 13:49:45

标签: php css class

在while循环中的下面的表格行中设置样式时,没有显示边框?为什么?背景颜色设置工作正常,但不是这样......没有边框显示...

    // Build Result String
$display_table = "<table>";
while($row = mysql_fetch_array($qry_result)){

$display_table .= "<tr style='border-top-width: thin; border-top-style: solid;'>"; //  wont work here, why????? But if I set bgr color to something, the bgr color works, but not the border thing... hmmmmmm

$display_table .= "<td width='110' rowspan='2'>BILD HÄR</td>";
$display_table .= "<td width='377' height='15'>$row[headline]</td>";
$display_table .= "<td width='67' rowspan='2'>$row[insert_date]</td>";
$display_table .= "</tr>";
$display_table .= "<tr>";
$display_table .= "<td height='15'>$row[price]:-</td>";
$display_table .= "</tr>";
}

$display_table .= "</table>";
echo $display_table;

3 个答案:

答案 0 :(得分:3)

行没有边框。细胞呢。将border-top-style: solid移至td内的tr元素。

答案 1 :(得分:3)

css并不总是在tr元素上工作,因为它只是一个容器标记,尝试在tr上放一个类并使用样式表来设置它的样式

e.g:

<style type="text/css">
    .myrow td
    {
        border-top:solid 1px black;
    }

</style>

<table>
    <tr class="myrow">
        <td>...

答案 2 :(得分:1)

您可以尝试使用这些样式

table {
  border-collapse:collapse;
}

td {
  border-top: 1px solid black;
}
相关问题