简体   繁体   中英

Prevent hover over active state

How to prevent hovering button,div,li if it already has active status by means of css?

#list-of-tests .item-test:hover {
    background-color: #4d5f75;
    border: solid 1px #4d5f75;
}

#list-of-tests .item-test:active {
    background-color: #93c3cd;
    border: solid 1px #93c3cd;
}

Two ways:

1) Use !important for the :active state:

#list-of-tests .item-test:active {
    background-color: #93c3cd !important;
    border: solid 1px #93c3cd !important;
}

2) Specify multiple states:

#list-of-tests .item-test:active,
#list-of-tests .item-test:active:hover {
    background-color: #93c3cd;
    border: solid 1px #93c3cd;
}

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