Delay mouseout/hover with CSS3 transitions

前端 未结 2 1353
一整个雨季
一整个雨季 2020-12-03 10:37

I\'ve got a box that changes size when being hovered. However, I would like to delay the mouseout stage, so that the box keep the new size for a few seconds, before getting

2条回答
  •  [愿得一人]
    2020-12-03 11:12

    div {
        width: 70px;
        -webkit-transition: .5s all;   
        -webkit-transition-delay: 5s; 
        -moz-transition: .5s all;   
        -moz-transition-delay: 5s; 
        -ms-transition: .5s all;   
        -ms-transition-delay: 5s; 
        -o-transition: .5s all;   
        -o-transition-delay: 5s; 
        transition: .5s all;   
        transition-delay: 5s; 
    }
    
    div:hover {
        width:130px;
        -webkit-transition-delay: 0s;
        -moz-transition-delay: 0s;
        -ms-transition-delay: 0s;
        -o-transition-delay: 0s;
        transition-delay: 0s;
    }
    

    This will trigger the mouseover state right away, but wait 5 sec till the mouseout is triggered.

    Fiddle

提交回复
热议问题