Simple css :before:hover not working? CSSlint no errors?

元气小坏坏 提交于 2019-12-10 14:34:16

问题


http://jsfiddle.net/nicktheandroid/k93ZK/2/

This should be really simple, I just don't understand why it's not working. When hovering over the :before it should change it's opacity to 1, but it doesn't. Why?

p {
    padding-top:15px;
    position:relative;
}

p:before {
    display:block;
    width:55px;
    height:55px;
    content: 'hello';
    background:#fff;
    padding:5px 10px;
    position:absolute;
    right:0;
    opacity:.5;
    -webkit-transition: all 0.3s ease-in-out;

}

p:before:hover {
    opacity:1;
    bakcground:#000;
}

EDIT: I'm using Chrome.


回答1:


Instead of p:before:hover, you need p:hover:before.

See: http://jsfiddle.net/k93ZK/3/




回答2:


If you want to let it work in Internet Explorer, just add the following code in your css:

p:hover{}

That's all.

Working example for Internet Explorer (10):

http://jsfiddle.net/k93ZK/63/



来源:https://stackoverflow.com/questions/6884320/simple-css-beforehover-not-working-csslint-no-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!