首页 > 解决方案 > 如何防止悬停/访问的链接颜色更改

问题描述

我想在链接悬停/已访问时保持默认的未访问链接颜色。我已经看到了这个相关的问题,但它需要您对颜色进行硬编码,我不想这样做,因为默认链接颜色可能因浏览器而异。这是我尝试过的:

a:hover, a:visited {
    /* both of these change it to white, which is the color of the parent element */
    color: inherit;
    color: currentColor;
    /* this changes it to black, i think since it's the color of the root element */
    color: initial;
}

标签: htmlcss

解决方案


推荐阅读