简体   繁体   English

如何防止此jQuery文本面板在第一次悬停时从顶部滑动到底部?

[英]How can I prevent this jquery text panel from sliding top to bottom the first time it's hovered?

When the page is first loaded, and the image is hovered over for the first time, the sliding panel slides down from the top to the bottom. 首次加载页面并第一次将图像悬停在该页面上时,滑动面板从顶部滑到底部。 But ever time you hover over it after that, it slides up from the bottom - which is what I want. 但是,每当您将鼠标悬停在它上面时,它就会从底部向上滑动-这就是我想要的。 I don't want it to slide down from the top the first time it's hovered over. 我不希望它第一次悬停时从顶部滑落。 Is there any way to make it just slide up every time it's hovered over? 有什么方法可以使它每次滑过时都向上滑动吗? I'm sure there's some simple solution but I'm not very familiar with javascript. 我敢肯定有一些简单的解决方案,但我对javascript不太熟悉。

<div class="boxgrid captionfull">  
<img src="http://s17.postimage.org/arxuilf9r/jareck.jpg"/>  
<div class="cover boxcaption">  
    <h3>Jarek Kubicki</h3>  
    <p>Artist<br/><a href="<a class="linkification-ext" title="Linkification: http://www.nonsensesociety.com/2009/03/art-by-jarek-kubicki/" href="http://www.nonsensesociety.com/2009/03/art-by-jarek-kubicki/">http://www.nonsensesociety.com/2009/03/art-by-jarek-kubicki/</a>" target="_BLANK">More Work</a></p>  
</div>  

  .boxgrid{  
  width: 325px;  
  height: 260px;  
  margin:10px;  
  float:left;  
  background:#161613;  
  border: solid 2px #8399AF;  
  overflow: hidden;  
  position: relative;  
}  


  .boxgrid img{  
  position: absolute;  
  top: 0;  
  left: 0;  
  border: 0;  
}
  .boxcaption{  
  float: left;  
  position: absolute;  
  background: #000;  
  height: 100px;  
  width: 100%;  
  opacity: .8;  
  /* For IE 5-7 */  
  filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80);  
  /* For IE 8 */  
  -MS-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";  
}
  .captionfull .boxcaption {  
  top: 260;  
  left: 0;  
}

 $(document).ready(function(){  
    $('.cover').hide();
    $('.boxgrid.captionfull').hover(function(){  
        $(".cover", this).stop().animate({top:'160px'},{queue:false,duration:160}).show();  
    }, function() {  
        $(".cover", this).stop().animate({top:'260px'},{queue:false,duration:160});  
    });  
});

http://jsfiddle.net/scottm29/NUpfz/1/ http://jsfiddle.net/scottm29/NUpfz/1/

Define a startup css to your element: 为您的元素定义一个启动CSS:

Here is jsFiddle. 这是jsFiddle。

.boxcaption{ 
    ...
    top:260px; 
}

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

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