简体   繁体   English

jQuery向下滑动切换,不可能?

[英]jQuery slide down toggle, impossible?

I want to do a slide down with jQuery, but I can't find it anywhere. 我想用jQuery向下滑动,但我无法在任何地方找到它。

I do not want it to scale as it slides 希望它随着滑动扩展
I do want it to perform this action ( click slide ), but vertically down, not horizontally right. 我确实希望它执行此操作 (单击幻灯片),但是垂直向下,而不是水平向右。

UPDATE : 更新:

So here's the final functional code! 所以这是最终的功能代码!

$(this).toggle(
    "slide", 
    {
        direction: 'up',
        duration: 'slow',
        easing: 'easeOutQuart'
    }
);

Read the API-Docs: http://docs.jquery.com/UI/Effects/Slide 阅读API-Docs: http//docs.jquery.com/UI/Effects/Slide

You can Slide in every direction using the direction-option. 您可以使用direction-option滑动每个方向。

Demo: http://www.jsfiddle.net/doktormolle/befbE/ (I set the width/height of the image inside the sliding element to 100%, so you can see, the image is not scaled, it's clipped, guess that's what you are looking for) 演示: http//www.jsfiddle.net/doktormolle/befbE/ (我将滑动元素内图像的宽度/高度设置为100%,所以你可以看到,图像没有缩放,它被剪裁,猜测是你在寻找什么)

If you position the element absolutely in a container and attach it to the bottom (ie. position:absolute;bottom:0; ) you can use the blind effect and it will slide down to the bottom from the top. 如果将元素绝对放置在容器中并将其附加到底部(即position:absolute;bottom:0; ),您可以使用盲效,它将从顶部向下滑动到底部。 See here 看到这里

If you want it the make own ur you, can you use .animate() and you using css. 如果你想要它自己创建你,你可以使用.animate()和你使用CSS。

something like: 就像是:

css: CSS:

#elm { width: 150px; height: 80px; position: absolute; left: -150px; }

script: 脚本:

// let it animate
$('#elm').animate({ display: 'block', left: 0 }, 'fast');

else if you dont wanna make it on your own, use that jQuery UI 'slide' effect? 否则,如果你不想自己做,使用jQuery UI'幻灯片'效果?

I know what you mean - the items inside the DIV or whatever you are animating look like they are squahsed, and then expand. 我知道你的意思 - DIV中的物品或者你动画的任何东西看起来像是被喷射,然后扩展。

Maybe consider hiding the element behind another and either move the masking element up and out of the way or slide the hidden element down using .animate()? 也许可以考虑将元素隐藏在另一个元素之后,然后向上移动掩蔽元素,或者使用.animate()向下滑动隐藏元素?

jQuery .click .animate to move down, then back up jQuery .click .animate向下移动,然后向上移动

This may help. 这可能有所帮助。

You can easily achieve this with an inner container that has fixed dimentions. 您可以使用具有固定尺寸的内部容器轻松实现此目的。

See this live example . 看到这个实例 In the fiddle, the first div is without the inner container. 在小提琴中,第一个div没有内部容器。

This way when the outer container animates (width/height) the inner container does not grow, simply reveals . 这样,当外部容器动画(宽度/高度)时,内部容器不会生长,只需显示

Consider your image of height 150px 考虑你的身高150 像素的图像

First apply height="0" 首先应用height =“0”

Use animate to achieve slide down effect 使用animate实现向下滑动效果

<img src="http://www.google.com/images/nav_logo29.png" id="image_scale" width="200" height="0" />

<script>
$(document).ready(function(){
    $("#image_scale").animate({height:"150px"},"5000");
});
</script>

Absolutely position the element you are wanting to slide in and out and use .animate() to change it's position. 绝对定位您想要滑入和滑出的元素,并使用.animate()来改变它的位置。 You can have it slide in from the top, bottom, left, right, on the diagonal or however you want with this method. 您可以从顶部,底部,左侧,右侧,对角线滑入,或者您可以使用此方法。

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

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