简体   繁体   中英

Fix mouseover with toggle buttons and child DIV's

I have a toggle script that works great, but I'm trying to add a mouseover effect and I'm having trouble with it.

I have four tags, two of which are simple DIV's with background colors, and I have two additional Buttons with background images.

I created a mouseover effect for all tags, but it doesn't look right when I click on a button. Once I click a button, the button needs to change background-position upon click and the mousever should stop over the buttons.

Here is my link: http://jsfiddle.net/eriksnet/9cr4F/1/

Thank you.

It's because #r6:hover .gnM has a higher precedence over .button-toogle-on . CSS has an hierarchy of CSS, based on where it's defined, if it's inline or not, how many elements you specify. Read more here .

Anyways, this works:

#r6 #bxGender .button-toggle-on {
    background-position: 0 -120px
}

jsfiddle: http://jsfiddle.net/9cr4F/3/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM