hover change image

可以不用js,仅仅用css里面的hover +功能,来切换图片。这样就能将hover和点击分开。灵感来源于以下

缺点:

按钮之间必须紧密,因为离开之后会回到默认图片,因为没有增加类似active的类。

点击编辑代码
<script>
$(function() {
$('.press').mouseenter(function() {
$('body').addClass("inverse");
});
});
</script>
mouseleave如果不增加效果就是停留在当前页面。
<script>
$(function() {
$('.press').mouseenter(function() {
$('.content').addClass("actived");
}).mouseleave(function () {
$('content').removeClass("actived");
});
});
</script>

.div1:hover ~ .div2 {
background: yellow;
}

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Fill out this field
Fill out this field
请输入有效的电子邮箱地址。