开发者

:hover{} precedence in gecko

开发者 https://www.devze.com 2023-02-16 04:19 出处:网络
writing somewhat of a css hack, styling for :hover {} works interestingly, but browsers treat a:hover differently for full links VS hash tags.

writing somewhat of a css hack, styling for :hover {} works interestingly, but browsers treat a:hover differently for full links VS hash tags.

from http://inqdrops.com/welcom/

a, a:active, a:visited { color: #765; text-decoration: none;}

:hover { color: #ff5e99; text-decoration:overline; background: #222}

for this code, hovers on <a href='http://what.eva/'></a> and <a href='#whateva'></a> behave differently. They also differ for webkit and gecko.

Can someone explain what is happening?

--

EDITED FOR EXPLANATION ON SOLUTION

the answer by @babtek pointed me in the right direction, and the solution was to expand the 开发者_如何学Ccss rule to :hover, :visited:hover {...}


I think a:visited ends up being more specific than :hover since it has a tagname as well... your "#" links might not get flagged as visited?


WHy don;t you change the css to

a:hover


in case someone is intersted, what i was missing was the css rules' order. plus a psuedo:psuedo rule

a, a:active, a:visited {color: #765; text-decoration: none;}
:hover, :visited:hover { color: #ff5e99; text-decoration:overline; background: #222}

thanks fo the tips

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号