在CSS中格式化表格

时间:2012-03-23 14:14:41

标签: php css html-table

我有我的html表格,我想指定每个单元格的高度,字体,字体颜色以及各种各样的东西......在我使用内联样式绕过它之前我想把它放到我的CSS却无法做到!我已经添加了一个类名并正确引用但由于某种原因,该表的任何属性都不会与CSS对话。这是唯一有此问题的页面元素:

echo "<table class='blogtable'><tr>";

    echo "</tr>\n";

while($row = mysql_fetch_assoc($result))
{

    $usn1 = $row['username'];
    $tml1 = $row['timeleft'];
    $bge1 = $row['blogentry'];
    $bge2 = substr($bge1,0,50);
    $tml2 = substr($tml1,0,11);

    echo "<tr class='blogrow'>";



        echo "<td class='bloglink'>";
        echo "<a class='bloglink' href='blog.php' >".$bge2."...</a>";
        echo "</td>";
        echo "<td class='blogunderline'>";
        echo "By";
        echo "</td>";
        echo "<td class='blogunderline'>";
        echo $usn1;
        echo "</td>";
        echo "<td class='blogunderline'>";
        echo " - ";
        echo "<td class='blogunderline'>";
        echo $tml2;
        echo "</td>";



    echo "</tr>";
}
echo "</table>";



a.bloglink{
    color: #696969;
    text-decoration: none;

}

table.blogtable{

    font-family: arial; 
    color:#696969; 
    font-size: 11pt; 
    line-height: 28px;
}

td.blogunderline{

    border-bottom-style:dotted; 
    border-width: 0.5px;

}

但html说....不,谢谢!

tr.blogrow{
     border-bottom:solid 0.5px; 
     text-decoration:none;

}

编辑:我很尴尬地说,但我打开了两个CSS文件,一个在主服务器上,一个在硬盘上,我正在编辑错误的一个!对不起,对不起!

1 个答案:

答案 0 :(得分:2)

您的tr.blogrow {border-bottom:solid 0.5px}没有附加颜色。也没有td.blogunderline。

你的CSS不会'两次'引用自己。当你定义tr.blogrow时,删除tr,然后使用.blogrow(与你的其他CSS项目table.blogtable和td.blogunderline相同)

echo "<table class='blogtable'><tr>";

                echo "</tr>\n";

            while($row = mysql_fetch_assoc($result))
            {

                $usn1 = $row['username'];
                $tml1 = $row['timeleft'];
                $bge1 = $row['blogentry'];
                $bge2 = substr($bge1,0,50);
                $tml2 = substr($tml1,0,11);

                echo "<tr class='blogrow'>";



                    echo "<td class='bloglink'>";
                    echo "<a class='bloglink' href='blog.php' >".$bge2."...</a>";
                    echo "</td>";
                    echo "<td class='blogunderline'>";
                    echo "By";
                    echo "</td>";
                    echo "<td class='blogunderline'>";
                    echo $usn1;
                    echo "</td>";
                    echo "<td class='blogunderline'>";
                    echo " - ";
                    echo "<td class='blogunderline'>";
                    echo $tml2;
                    echo "</td>";



                echo "</tr>";
            }
            echo "</table>";



.bloglink{
color: #696969;
text-decoration: none;

}

.blogtable{

font-family: arial; 
color:#696969; 
font-size: 11pt; 
line-height: 28px;
}

.blogunderline{

border-bottom:dotted 1px blue

}
 .blogrow{ border-bottom:solid 1px blue; text-decoration:none;

}

请记住,您必须使用整个像素,而不是半像素,必须为边框定义颜色,并且<tr>样式将覆盖您的<td>边框样式(<td class="blogunderline">不会应用蓝色虚线边框底部。