【发布时间】:2014-03-19 05:42:45
【问题描述】:
我正在尝试为引导程序中的悬停缩略图创建自定义效果。关于如何更有效地编写此代码的任何想法?似乎有时彩色 div 会向下滑动,但不会显示其中的标题和 ph 元素
js
$("[rel='tooltip']").tooltip();
$('.thumbnail').hover(
function(){
$(this).find('.caption').slideDown(250).animate({"background-color":"rgba(242, 200, 2, 0.75)"},900);
$(this).find('.captionhead').show().animate({"color":"black","font-size":"24px"},400,"easeOutBounce");
$(this).find(".captionph").show().animate({"color":"black","font-size":"30px"},400,"easeOutBounce");
},
function(){
$(this).find('.caption').slideUp(250).animate({"background-color":"rgba(66, 139, 202, 0.75)"},600, function(){
$(this).find('.captionhead').animate({"color":"white","font-size":"18px" },100).hide();
$(this).find(".captionph").animate({"color":"black","font-size":"10px"},100,"easeOutBounce").hide();
}); //.fadeOut(205)
}
);
html
<div class="col-sm-6 col-md-3 bpad">
<div class="thumbnail">
<div class="caption">
<h4 class="captionhead">Sliced Bread</h4>
<p class="captionph">description</p>
</div>
<div>
<img class="img-circle img-responsive" src="photo/1.jpg" alt="logo">
</div>
</div>
</div>
【问题讨论】:
-
首先,完全摆脱
(this).find(...部分,你不需要它们,其次,关于你想要实现的目标以及正在发生的事情的更多信息会很多赞赏;) -
无需删除 $(this).find..(它的存在是为了
context) -
注意!更正了我的回答,谢谢!
标签: jquery jquery-ui twitter-bootstrap animation