gpt4 book ai didi

javascript - 具有 CSS 过渡效果的 jquery 悬停功能仅适用于第二次悬停

转载 作者:太空宇宙 更新时间:2023-11-04 02:46:44 25 4
gpt4 key购买 nike

很奇怪。以下代码仅适用于 second 悬停。例如,页面已加载,切换有效,但过渡动画直到第二次悬停才起作用,每次都是一致的。

jQuery:

$('.greenBox').hover(function(){
$(this).addClass('expanded');
$(this).removeClass('contracted');
}, function(){
$(this).removeClass('expanded');
$(this).addClass('contracted');
});

CSS:

.greenBox {
background-image: url("../images/background_bubble.png");
background-repeat: no-repeat;
// transition:max-height .5s linear;
// background: linear-gradient(#69af38, #8fba35);
transition: .8s;
color: #FFF;
width: 310px;
height: 137px;
position: relative;
overflow:hidden;
z-index: 2;
display: block;
// -moz-transition: background-color 0.5s ease, height 0.5s ease, bottom 0.5s ease;
// -o-transition: background-color 0.5s ease, height 0.5s ease, bottom 0.5s ease;
// -webkit-transition: background-color 0.5s ease, height 0.5s ease, bottom 0.5s ease; /* Chrome 1-25, Safari 3.2+ */
// transition: background-color 0.5s ease, height 0.5s ease, bottom 0.5s ease;
overflow: hidden;
bottom: 7px;
// -webkit-clip-path: polygon(0% 0%, 100% 0%, 100% 75%, 60% 75%, 49% 86%, 37% 75%, 0% 75%);
// clip-path: polygon(0% 0%, 100% 0%, 100% 75%, 60% 75%, 49% 86%, 37% 75%, 0% 75%);
.noLink {
color: #FFF;
&:hover {
cursor: auto;
color: #FFF;
background: linear-gradient(#69af38, #8fba35);
}
}
}

和。

.contracted {
// transition: 11s;
max-height: 150px;
overflow:hidden;
}

和。

.expanded { 
height: auto;
min-height:150px;
max-height:750px;
// transition: 11s;
// margin-top:5px;
// to make the box move up add back the bottom 300px
// bottom: 300px;
background: linear-gradient(#812990, #9e248e);
-webkit-transition-timing-function: linear;
transition-timing-function: linear;
background: -webkit-linear-gradient(#812990, #9E248E);
}

最佳答案

您需要确保元素以 contracted 类开头。在我补充说它也只适用于我的第二次悬停之前。

fiddle :http://jsfiddle.net/AtheistP3ace/czrqkorn/

<div class="greenBox contracted"></div>

关于javascript - 具有 CSS 过渡效果的 jquery 悬停功能仅适用于第二次悬停,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33744555/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com