May 15th, 2009ie css selector issue
最近写了一些html, 遇到一个很郁闷的问题, 大致是下面的, 我写了一些链接, 大致如下:
<a class="actionlink" onclick=’myfunction(this);'>mylink</a>
为它写了一个css, 如下:
a.actionlink {
display:block;text-decoration: none;
color: #62C2CC;
outline: none;
}
a.actionlink:hover {
display:block;color: blue;
text-decoration: underline;
}
a.actionlink:visited {
display:block;color: $62c2cc;
}
a.actionlink:active {
display:block;color: red;
}
链接在firefox下面显示的完全正常, 可是在ie7/8下却死活无法正常显示在鼠标移上去时的颜色, 网上找了很久, 看到一些相关的ie8的bug, 像css selector的问题, 这里有一个列表, 本来以为其中的一个css子对象选择符的bug是这个有关, 但是我已经把它改成了直接的类, 所以应该不是那个问题.
两天郁闷的尝试都没有成功, 今天再看相关的文档, 在看到选择符的时候, 偶然看到这么一句:
The document language determines which elements are hyperlink source anchors. For example, in HTML4, the link pseudo-classes apply to A elements with an "href" attribute. Thus, the following two CSS 2.1 declarations have similar effect:
a:link { color: red } :link { color: red }
这回忽然注意到其中红色的部分, 难道真和这个有关? 于是试着加上href="#", 之后, 果然一切都好了!……
<a href=”#” class="actionlink" onclick=’myfunction(this);'>mylink</a>






