gpt4 book ai didi

css - WebKit 错误?悬停状态不会应用于通过 CSS 插入的内容

转载 作者:行者123 更新时间:2023-11-28 09:51:01 25 4
gpt4 key购买 nike

似乎有一个 WebKit 错误不会将悬停状态应用于通过 CSS 中的 content 属性插入的内容。

有人知道解决这个问题的方法吗?

a:before {
content: "Hover Over Me";
}
a:hover {
color: red;
}

示例:http://jsfiddle.net/wdmedal/X4gjL/1/


结论:这个错误似乎只影响内联元素。

解决方法:将元素的显示类型设置为inline-block(或其他显示类型)。

最佳答案

这对我有用 http://jsfiddle.net/X4gjL/5/

a:before {
content: "Hover Over Me";
}
a.foo:hover {
color: red;
}
a.foo
{
display:block;
}​

------------编辑--------

感谢BoltClock指出这一点,使它成为 inline-block 不会像 block 那样默认使宽度为 100%。 http://jsfiddle.net/X4gjL/6/

a:before {
content: "Hover Over Me";
}
a.foo:hover {
color: red;
}
a.foo
{
display:inline-block;
}​

关于css - WebKit 错误?悬停状态不会应用于通过 CSS 插入的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12648127/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com