使用CSS样式化活动锚元素 [英] Styling active anchor elements with css

查看:55
本文介绍了使用CSS样式化活动锚元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难找到具有彩色的活动锚的css解决方案...

I have some trouble to find a css solution for having an active anchor colored...

活动锚为什么不是红色,所以如果单击 momo莫莫保持红色?还是为此使用了错误的伪类?

Why are the active anchors not red so that if clicked on "momo" momo keeps red? Or is active the wrong pseudoclass for that?

<!doctype html>
<html lang="en">

    <head>
        <meta charset="utf-8" />
        <title>test</title>
    <style type="text/css">
        a:active{
        color:red;
        }
        a:hover{
        color:yellow;
        }
        </style>
    </head>

    <body>
    <ul> Navigation
    <li class="subli"><a href="#momo">momo</a></li>
    <li class="subli"><a href="#ipsi">ipsi</a></li>
    </ul>
    </body>

</html> 

感谢
Juru

Thanks Juru

推荐答案

:active 表示正在被激活,例如当焦点对准 时,按下Enter键或将鼠标悬停 时,将按下鼠标按钮。 (请注意,由于在:active 之后有:hover ,因此您始终会覆盖它以进行鼠标激活)

:active means "While being activated" e.g. when it is focused and the enter key is pressed or while it is hovered and the mouse button is being depressed. (Note that since you have have :hover after :active you'll always override it for mouse activates)

对于具有解析为当前位置的href值的锚点,没有伪类。为此,您需要修改HTML(最好在到达浏览器之前,但也可以使用JS)。

There is no pseudo-class for "Anchor with an href value that resolves to the current location". For that you need to need to modify the HTML (preferably before it gets to the browser, but you can use JS as well).

这篇关于使用CSS样式化活动锚元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆