将超链接从整个表格单元格更改为表格单元格中的文本

时间:2010-03-03 03:03:53

标签: html css

在下表中,整个单元格是超链接。如何只在单元格超链接中创建文本?相应的CSS也在下面。

提前致谢,

约翰

<?php
    echo "<table class=\"samplesrec\">";
    while ($row = mysql_fetch_array($result)) { 
        echo '<tr>';
        echo '<td class="sitename1"><a href="http://www.'.$row["url"].'">'.$row["title"].'</a></td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td class="sitename2"><a href="http://www.'.$row["url"].'">'.$row["username"].'</a></td>';
        echo '</tr>';
        }
    echo "</table>";    

?>


table.samplesrec {
    position:absolute;
    left:300px;
    top:125px;
    text-align: left;
    font-family: Arial, Helvetica, sans-serif ;
    font-weight: normal;
    font-size: 16px;
    color: #000000;
    width: 1000px;
    table-layout:fixed;
    background-color: #FFFFFF;
    border: 2px #FFFFFF;
    border-collapse: collapse;
    border-spacing: 2px;
    padding: 1px;
    text-decoration: none;
    vertical-align: text-bottom;    

}

table.samplesrec td {
   border: 2px solid #fff;  
   text-align: left; 
   height: 18px;
   overflow:hidden;

}

table.samplesrec td a{
   display: block;
   padding: 2px;
   color: #000000;
   text-decoration: none;
   overflow:hidden;
   height: 18px;
}

table.samplesrec td a:hover{
   background-color: #FFFFFF;
   display: block;
   padding: 2px;
   color: #FF0000;
   text-decoration: none;
   overflow:hidden;
   height: 18px;
}   

.sitename1 { width: 550px;
            overflow:hidden !important;
            color: #000000;
            vertical-align: 

}

.sitename2 { width: 50px;
            overflow:hidden !important;
            color: #793D00;
            font-size: 12px;
            font-weight: bold;
            height: 18px;
            padding-bottom: 18px;

}

1 个答案:

答案 0 :(得分:1)

display:blocktable.samplesrec td a移除table.samplesrec td a:hover