【发布时间】:2014-01-23 12:37:11
【问题描述】:
我正在寻找一种方法来很好地做到这一点 fiddle 但看不到工作... 我仍在寻找谷歌和 stackoverflow 的表兄弟以找到一个好的解决方案,但是,naaaarrhg ......没有运气。
$('.box').stop().mouseenter(function(){
var zoom = 40;
var total = 5;
var box = $(this);
var altboxes = $('.box').not(box);
var larg = (100-zoom)/(total-1);
$(altboxes).animate({
width:larg+"%",
},{duration:300,queue:false});
$(box).animate({
width:zoom+"%",
},{duration:300,queue:false});
});
$('.box').stop().mouseleave(function(){
var box = $(this);
var altboxes = $('.box').not(box);
var total = 5;
var larg = 100/total;
$(box).animate({
width:larg+"%",
},{duration:300,queue:false});
$(altboxes).animate({
width:larg+"%",
},{duration:300,queue:false});
});
如您所见,最后一个 div 会在动画完成后出现并返回。这不是在这里寻找的东西。我希望 div 能够很好地适应父宽度。我目前正在尝试使用 animate() 选项中的 function step 来修复它,我还没有找到解决方案。 (我真的不知道它是如何工作的)
需要你的帮助,因为我是 jquery 的新手(从 2013 年 10 月开始使用它;))
谢谢大家!
【问题讨论】:
-
我将仅使用 css 进行侦察。类似jsfiddle.net/aamir/AW6Rh 或 onHover jsfiddle.net/aamir/AW6Rh/1
-
我没有指定它,但我喜欢一些平滑和可调整的东西。还是谢谢。
标签: jquery html jquery-animate width mouseenter