html mouseover css,html - MouseOver and MouseOut In CSS - Stack Overflow

CSS itself does not support a mousein or mouseout selector.

The :hover selector will apply to the element while the mouse is over it, adding the style when the mouse enters and removing the style when the mouse leaves.

The nearest approach is to define the styles which you would place in mouseout within your default (non-hover) styles. When you mouse-over the element the styles within hover will take effect, emulating a mousein, and when you move your mouse off the element the default styles will take effect again, emulating mouseout.

Here is an example, taken from here:

div {

background: #2e9ec7;

color: #fff;

margin: 0 auto;

padding: 100px 0;

-webkit-transition: -webkit-border-radius 0.5s ease-in;

-moz-transition: -moz-border-radius 0.5s ease-in;

-o-transition: border-radius 0.5s ease-in;

-ms-transition: border-radius 0.5s ease-in;

transition: border-radius 0.5s ease-in;

text-align: center;

width: 200px;

}

div:hover {

background: #2fa832;

-webkit-border-radius: 100px;

-moz-border-radius: 100px;

border-radius: 100px;

-webkit-transition: all 1s ease;

-moz-transition: all 1s ease;

-o-transition: all 1s ease;

-ms-transition: all 1s ease;

transition: all 1s ease;

-webkit-transform: rotate(720deg);

-moz-transform: rotate(720deg);

-o-transform: rotate(720deg);

-ms-transform: rotate(720deg);

transform: rotate(720deg);

}

The transitions defined for the div:hover style will take effect when the mouse enters (and hover is applied). The transitions for the div style will take effect when the mouse leaves (and hover is removed). This results in the mousein and mouseout transitions being different.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值