如何使用css hover更改跨度的内容?

时间:2022-03-13 19:55:26

I can set the text of a span with this css.

我可以用这个css设置跨度的文本。

.tracking-true .tracking-button-text:before
{
    content:"Tracking";
}

But I would like to change the text on hover Something like this but I can't get it to work.

但我想改变悬停上的文字这样的东西,但我不能让它工作。

.tracking-true .tracking-button-text:hover
{
    content:"Untrack";
}

Can this be done in css?

这可以用css完成吗?

Update: Much like * uses :hover to change the cursor to a pointer or change a background color as a ui hint I am trying to convey to the user the same thing. This element can be clicked on and something will happen. I don't feel this is an innaporopriate use of CSS.

更新:很像*使用:悬停将光标更改为指针或更改背景颜色作为ui提示我试图向用户传达相同的内容。可以单击此元素并发生某些事情。我觉得这不是对CSS的使用。

1 个解决方案

#1


3  

Do this:

.tracking-true .tracking-button-text:before
{
    content:"Tracking";
}

.tracking-true .tracking-button-text:hover:before
{
    content:"Untrack";
}

#1


3  

Do this:

.tracking-true .tracking-button-text:before
{
    content:"Tracking";
}

.tracking-true .tracking-button-text:hover:before
{
    content:"Untrack";
}