Search code examples
csscss-selectorspseudo-class

CSS - double pseudo classes.. is this possible


.onoffswitch-checkbox:checked ~ .onoffswitch-inner:hover {
   background: #0095cd;
}

Is this possible?

Basically I want a hover class on the .onoffswitch-inner when the sibling checkbox is checked.


Solution

  • Just go ahead. It works:

    http://jsfiddle.net/trungdq88/z38Y6/1/

    HTML

    <label>
        <input type="checkbox" class="onoffswitch-checkbox"/> Check this box
        <div class="onoffswitch-inner">And hover here</div>
    </label>
    

    CSS:

    .onoffswitch-checkbox:checked ~ .onoffswitch-inner:hover {
       background: #0095cd;
    }