簡體   English   中英

表中的 Href 鏈接顏色

[英]Href link color in table

我在單元格中有一個帶有 href 鏈接的 html 表,但我不知道如何設置此 href 鏈接顏色。 背景顏色(紅色)工作正常,但簡單的“顏色:綠色”不行。

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>";

您應該避免添加內聯樣式。

使用外部樣式表,您的文檔將更易於閱讀和維護。

有條件地向表格單元格添加一個類,然后在樣式表中利用該類。

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

CSS:

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

我相信我可以建議一種更簡潔的方式來編碼,但你沒有提供太多的上下文。

Ps 我希望id='bot'是頁面獨有的。

嘗試遵循 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