最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Horizontal Overflow with slideDown()slideUp() - Stack Overflow

programmeradmin2浏览0评论

I am trying to use the slideUp() / slideDown() to animate the revelation of a page element but have had trouble with a relatively positioned icon with a negative (outside the element) placement. While these animations execute it sets overflow to hidden rendering my icon cut in half until the animation pletes.

The JSFiddle here illustrates my issue. I need the horizontal overflow of the blue box to be visible during the whole execution of the animation instead of magically appearing at the end. I also need the vertical overflow to remain hidden.

I've tried amending,

$(this).parent().find("div:eq(0)").slideDown(1000).css("overflow-x", "visible");

but it seems to be ignored and using,

$(this).parent().find("div:eq(0)").slideDown(1000).css("overflow", "visible");

also makes the vertical overflow visible.

Any insight would be greatly appreciated.

I am trying to use the slideUp() / slideDown() to animate the revelation of a page element but have had trouble with a relatively positioned icon with a negative (outside the element) placement. While these animations execute it sets overflow to hidden rendering my icon cut in half until the animation pletes.

The JSFiddle here illustrates my issue. I need the horizontal overflow of the blue box to be visible during the whole execution of the animation instead of magically appearing at the end. I also need the vertical overflow to remain hidden.

I've tried amending,

$(this).parent().find("div:eq(0)").slideDown(1000).css("overflow-x", "visible");

but it seems to be ignored and using,

$(this).parent().find("div:eq(0)").slideDown(1000).css("overflow", "visible");

also makes the vertical overflow visible.

Any insight would be greatly appreciated.

Share Improve this question asked Sep 30, 2015 at 18:43 E. AllisonE. Allison 884 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 8

Just wrap your divs like : div.clickEvent inside other div.hide

<div class="hide"><div class="clickEvent"> 
... 
</div>

https://jsfiddle/h9gtzp6f/37/

Try this:

$('.clickMe').toggle(function() {
    var div = $(this).parent().find("div:eq(0)").show();
    var parent = div.parent();
    var wrapper = $('<div>', {'class': 'hide wrapper', html: div});
    parent.append(wrapper);
    wrapper.slideDown({duration:1000, plete: function(){parent.append(div);wrapper.remove();}});
}, function() {
    var div = $(this).parent().find("div:eq(0)");
    var parent = div.parent();
    var wrapper = $('<div>', {'class': 'wrapper', html: div});
    parent.append(wrapper);
    wrapper.slideUp({duration:"fast", plete: function(){parent.append(div);wrapper.remove();div.hide()}});
});
发布评论

评论列表(0)

  1. 暂无评论