1

所以,

我正在使用 David Walsh在此处详述的 Jquery 集成两个窗格 DIV 。我已将他的代码迁移到JSfiddle并进行了一些调整,但动画似乎不起作用。如果有人知道我在代码中缺少什么,我将不胜感激输入!

-马卡

jQuery:

jQuery(document).ready(function() {
  jQuery(".itemJQuery").bind({
    mouseenter: function() {
      var self = jQuery(this), billboard = self.data("billboardElement");
      if(!billboard) {
        billboard = jQuery(jQuery(".item-billboard", this)[0]);
        self.data("billboardElement", billboard);
      }
      jQuery(billboard).stop().animate({
        "margin-top": "-200px"
      });
    },
    mouseleave: function() {
      jQuery(this).data("billboardElement").stop().animate({
        "margin-top": 0
      });
    }
  });
});

HTML:

<div class="item">
    <div class="item-billboard">
      <h3>Angry Birds</h3>
    </div>
    <div class="item-detail">
      <p>There's more detail about the item inside this DIV!</p>
    </div>
</div>

CSS:

.item {position: relative;width: 240px;overflow: hidden;border: 1px solid #ccc;}
.item {height: 200px;}      
.item a {text-decoration: none;color: #000;}     
.item-billboard, .item-detail {padding: 10px;height: 180px;}     
.item-billboard {margin-top: 0;background: red;}
.item-billboard h3 {font-size: 13px;font-weight: bold;color: #262626;font-family: "Open Sans", arial, sans-serif;}
.item-detail {background: #ececec;}
4

2 回答 2

2

更改jQuery(".itemJQuery")jQuery(".item"),它的工作原理。

代码:http: //jsfiddle.net/3BMfu/12/

于 2012-09-09T19:33:07.200 回答
1

我不了解大卫沃尔什,但在 SO,我们构建了这样的东西 :)

jsBin 演示

$('.item').on('mouseenter mouseleave',function(e){
    $(this).stop().animate({scrollTop: e.type=='mouseenter'?200:0 }, 400);    
});
于 2012-09-09T19:36:23.620 回答