Pergunta

Eu tenho este ícone css3 ok criado com css.http://jsfiddle.net/5c9gN/

JS:

$('.ok').mouseenter(function(){
    $(this).parent().find('.ok:after, .ok:before').css('background','#ccc');
    $(this).css('background','#33CC33');
});
$('.ok').mouseleave(function(){
    $(this).parent().find('.ok:after, .ok:before').css('background','#ccc');
    $(this).css('background','#ccc');
});

CSS:

.ok{height:40px; width:40px; display:block; position:relative; margin-left: auto; margin-right: auto;} 

.ok:after, .ok:before{content:''; height:32px; width:10px; display:block; background:   #ccc; position:absolute; top:6px; left:18px; transform:rotate(45deg);-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-o-transform:rotate(45deg);-ms-transform:rotate(45deg);}

.ok:before{height:16px; transform:rotate(-45deg);-webkit-transform:rotate(-45deg);-moz-transform:rotate(-45deg);-o-transform:rotate(-45deg);-ms-transform:rotate(-45deg); top:18px; left:6px;}

E estou tendo um pequeno problema ao tentar mudar a cor do ícone.Sempre muda a cor de fundo, não o ícone.Alguém pode ajudar-me?Obrigado

Foi útil?

Solução

Usando apenas CSS:

DEMONSTRAÇÃO

.ok:hover:after, .ok:hover:before {
    background: #33CC33;
}

Outras dicas

Adicione este css

.ok.mouseover:after, .ok.mouseover:before{
     background:    #33CC33;
}

e atualize seu código JS para este

$('.ok').mouseenter(function(){
    $(this).addClass('mouseover');
});
$('.ok').mouseleave(function(){
    $(this).removeClass('mouseover');
});
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top