Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebKit bug? Hover state does not get applied to content inserted via CSS

Tags:

css

webkit

There appears to be a WebKit bug that does not apply a hover state to content inserted via the content property in CSS.

Does anyone know a workaround for this?

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

Example: http://jsfiddle.net/wdmedal/X4gjL/1/


Conclusion: This bug seems to only affect inline elements.

Workaround: Set the display type of the element to inline-block (or another display type).

like image 314
wdm Avatar asked May 23 '26 07:05

wdm


1 Answers

This works for me http://jsfiddle.net/X4gjL/5/

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

-------------EDIT---------

Thanks to BoltClock for pointing this out, making it inline-block doesn't make the width 100% by default like block. http://jsfiddle.net/X4gjL/6/

a:before {
    content: "Hover Over Me";
}
a.foo:hover {
    color: red;
}
a.foo
{
    display:inline-block;
}​
like image 83
user1289347 Avatar answered May 24 '26 21:05

user1289347



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!