简体   繁体   English

jQuery的滑动div闪烁

[英]jquery sliding div are flickering

I am trying to make two divs sliding up and down on hover exactly like here: http://goo.gl/Ti1hjF (see the capable section). 我试图使两个div在悬停时上下滑动,就像这里一样: http : //goo.gl/Ti1hjF (请参阅功能强大的部分)。 after hovering, the content of second div is doing up and down. 悬停后,第二个div的内容在上下移动。 I am going nuts trying to solve it. 我疯了试图解决它。 what am I doing wrong? 我究竟做错了什么? here's the jquery : 这是jQuery:

$(".dormant").hover(function() {
var $detail = $(this).next(".detail")
if ($detail.is(":hidden")) {

    $detail.slideToggle(1000);
} else {
    $detail.slideUp('slow');
}
});

html: 的HTML:

<div class="col-md-4">
    <div class="detail-container">
  <div class="ivory dormant">
    <div class="col-md-3 col-xs-2 center-block"><span class="bigicon doormat"></span>    </div>
    <h4>PARTNERSHIP + RELATIONSHIP</h4>
    <p>We manage and deliver engagements and opportunities to further drive brand initiatives and further product and service objectives. We establish and implement targeted assessments which yield scalable results for our clients.</p>
    <div class="col-md-4 col-xs-3 center-block pop-up"><i class="glyphicon glyphicon-plus-sign"></i> details</div>
  </div>
  <div class="red detail">
    <div class="col-md-3 col-xs-2 center-block"><span class="bigicon doormat-white"></span></div>
    <h4>PARTNERSHIP + RELATIONSHIP</h4>
    <ul>
        <li>Asset Management</li>
        <li>Asset Development</li>
        <li>Consumer Introduction</li>
        <li>Relationship Management</li>
        <li>Channel Strategies</li>
    </ul>
   </div>
   </div>
  </div>

and css: 和CSS:

.ivory{
background:#e7e6e6;
padding:2em;
margin-top:2em;
}

.red{
background:#8b0000;
color:white;
padding:2em;
}
#capabilities .red h4{
    color:white;
}
.detail{
display:none;
position:absolute;
left:0;
top:0;
min-height:29em;
width:100%;
cursor:pointer;
}

.detail-container{
position:relative;
}

many thanks in advance. 提前谢谢了。 it is really driving me crazy. 这真的让我发疯。

jsFiddle jsFiddle

removing 去除

else {
    $detail.slideUp('slow');
}

should do the trick. 应该可以。

Here's an updated jsFiddle 这是更新的jsFiddle

I'm not sure whether you are looking for this or not.. I've changed the code like this. 我不确定您是否在寻找这个。.我已经更改了这样的代码。

$(".dormant").hover(function() {
var $detail = $(this).next(".detail")
if ($detail.is(":hidden")) {

 $detail.slideToggle(1000);
 } 
});

 $(".red.detail").click(function(){
 $(this).slideUp(1000);
 });

check this DEMO 检查这个演示

Updated demo 更新的演示

So, i think this still needs a bit of work, but to fix your immediately problem: 因此,我认为这仍然需要一些工作,但是要解决您的当前问题:

$(".dormant").hover(function(e) {    
        var $detail = $(this).next(".detail")
        $detail.slideToggle(1000);
        $detail.hover(function(e) {}, function(e) {
           $detail.slideUp('slow');
        });
    }, function() {}
);

Basically adding an empty function for hover-out stops the odd behaviour and at least puts you on the right lines. 基本上,为悬停添加一个空函数可以停止奇怪的行为,至少可以使您处于正确的位置。 I realise you're probably after an effect more akin to having the whole red div slide up, but this addresses your 'bouncy' problem. 我知道您可能会在效果上更类似于使整个红色div向上滑动,但这可以解决您的“弹性”问题。

jsFiddle jsFiddle

After removing $detail.slideUp('slow'); 删除$detail.slideUp('slow'); You can use onmousemove and onmouseout html properties to hide/show required div. 您可以使用onmousemoveonmouseout html属性来隐藏/显示所需的div。

This happened to me ones. 这发生在我身上。 I had an additional :hover on that div and the images didnt animate properly. 我在该div上附加了一个:hover,并且图像没有正确设置动画。 Check if you have two :hovers on the div. 检查div上是否有两个:hovers。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM