带 anchor 文本的 CSS

标签 css anchor

问题来了。我在页面中放置了一个 anchor 。但是这个 anchor 没有 href 属性:

<a onClick="javascript:submit(10);" onMouseOver="adjust(1)" onMouseOut="adjust(0)">Click Here</a>

这很好用。但我想让它一直带有下划线,我通过以下方式实现了它:

a
{
    text-decoration:underline;
}

现在我希望 Click Here 具有与默认(黑色)不同的颜色。我想,当鼠标悬停在颜色上时,颜色会发生变化,并在鼠标未悬停时返回到我设置的颜色。另外,我想更改与文本颜色相同的背景。

我怎样才能做到这一点?

PS:我已经在谷歌上搜索了将近 2 个小时,但找不到任何东西!!

更新:

这是我当前关于 anchor 的 CSS

a, a:link, a:active, a:visited {
    color: #00f;
    cursor: pointer;
    text-decoration: underline;
}
a:hover {
    color: #f00;    /* Red */
    background-color: #000;    /* Black */
}

最佳答案

color 属性可用于设置文本的颜色。试试这个 -

a
{
    text-decoration:underline;
    color: Red;
}

a:hover { color: Blue; }

关于带 anchor 文本的 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8498179/

相关文章:

javascript - 带有字符串值的 html anchor 标记重定向

jquery - 如何使 jQuery Mobile anchor 工作?

css - 如果容器 div 较小,如何将子 div 扩展到 100% 屏幕宽度?

php - Bootstrap 使用模态删除记录

html - Chrome : Parts of outline on links remain after focus removed (when outline-style is explicitly to "auto")

javascript - ReactCSSTransitionGroup : Keep appear/appearActive classes after transition?

html - css布局高度问题与网格布局

javascript - 使用javascript创建 anchor href并且链接中没有主机url

jQuery scrollTo 不工作的 body ,html 设置 100%

javascript - 将页面直接加载到 anchor 标记