发布于 2018-03-19 00:40:29
使用多选择器将解决您的问题。
$('#cart, .shopping-cart').hover(function(e) {
$(".shopping-cart").stop(true, true).addClass("active");
}, function() {
$(".shopping-cart").stop(true, true).removeClass("active");
}); 发布于 2018-03-19 04:43:33
使用纯css,您可能会做这样的事情。
.cart {
background-color: lightblue;
float: right;
text-align: right;
position: relative;
}
.list {
background-color: lightgreen;
height: 250px;
width: 300px;
border: 2px solid red;
right: 0;
position: absolute;
transition: 1s all;
transform: scale(0) ;
transform-origin: 100% 0%;
}
.cart:hover > .list {
transform: scale(1);
}<div>
<div class="cart">
This is a cart
<div class="list">
some long list
</div>
</div>
</div>
position: absolute是可选的(以及附带的css),只是如果您没有它,那么购物车就会和子程序的宽度一样长,这可能是可取的,也可能是不可取的。
发布于 2018-03-19 00:49:02
只需从这里删除“活动”即可。
$(".shopping-cart").stop(true, true).removeClass("active");对这一个
$(".shopping-cart").stop(true, true).removeClass("");https://stackoverflow.com/questions/49354189
复制相似问题