我正在展示链接,当用户点击它们时,这些链接会在数据库中被标记为已读。我希望根据数据库中的信息而不是用户的浏览器历史来设置已点击和未点击的链接样式。到目前为止,我使用了以下代码:
10 a:visited {
11 color: #444;
12 }
13
14 a:link {
15 font-weight: bold;
16 color:black;
17 }
18
19 .read {
20 color: #444!important;
21 }
22
23 .unread {
24 font-weight: bold!important;
25 color:black!important;
26 }
并且
<tr class="even">
<td><a class="read" href="example.com">blah</a></td>
</tr>
<tr class="odd">
<td><a class="unread" href="example.org">foo</a></td>
</tr>
当链接已被访问,但不是从此页面访问的(在数据库中仍标记为未读),我会得到奇怪的结果。例如,只有颜色有效,但重量无效等。
是否可能在样式冲突时有一个样式覆盖另一个样式?
谢谢!
编辑:更新代码以澄清
解决方案
10 a:link,
11 a:visited {
12 font-weight: bold;
13 color: black;
14 }
15
16 a.read {
17 color: #444;
18 font-weight: lighter !important; /* omission or even "normal" didn't work here. */
19 }
20
21 a.unread {
22 font-weight: bold !important;
23 color: black !important;
24 }
!important
的样式? - Aaron Franke