简体   繁体   English

表中的 Href 链接颜色

[英]Href link color in table

I have an html table with a href link in a cell and I dont know how can I set this href link color.我在单元格中有一个带有 href 链接的 html 表,但我不知道如何设置此 href 链接颜色。 Background color (red) works okay but the simple "color: green" no.背景颜色(红色)工作正常,但简单的“颜色:绿色”不行。

else if($row['OK']=='OK') // if the word is OK
            echo "<td style='background-color: red;'><div id='bot'><a href='nyugtaz.php?callsign=".$row['callsign']."'>$nyugtaze</a></div></td>";

The code is what I tried:

else if($row['OK']=='OK') // if the word is OK
            echo "<td style='background-color: red; color: green'><div id='bot'><a href='nyugtaz.php?callsign=".$row['callsign']."'>$nyugtaze</a></div></td>";

You should avoid adding inline styles.您应该避免添加内联样式。

Your document will be simpler to read and maintain with an external stylesheet.使用外部样式表,您的文档将更易于阅读和维护。

Conditionally add a class to the table cell, then leverage that class in your stylesheet.有条件地向表格单元格添加一个类,然后在样式表中利用该类。

} elseif ($row['OK'] == 'OK') {
    echo "<td class='okCell'><div id='bot'><a href='nyugtaz.php?callsign=".$row['callsign']."'>{$nyugtaze}</a></div></td>";

CSS: CSS:

.okCell {
    background-color: red;
}
.okCell a {   # handle all of the linked/visited/etc variations if you wish
    color: green;
}

I am sure I could advise a cleaner way to code this up, but you haven't offered much context.我相信我可以建议一种更简洁的方式来编码,但你没有提供太多的上下文。

Ps I hope that id='bot' is unique to the page. Ps 我希望id='bot'是页面独有的。

Try following CSS will help you.尝试遵循 CSS 会对您有所帮助。

 #bot a:link, #bot a:visited{ color:black; } #bot a:hover{ color:green; }
 <table> <tr> <td style='background-color: red;'><div id='bot'><a href='nyugtaz.php?callsign=".$row['callsign']."'>test</a></div></td> </tr> </table>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM