使div向下滑动而不向下推内容 [英] make a div slide down without pushing content down

查看:106
本文介绍了使div向下滑动而不向下推内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个例子这里

我不确定如何使div向下滑动,而是将内容保持在顶部,例如div向下滑动时不向下滑动.

im not sure how to make the div slide down but keeping the content at the top, as in not slide down when the div slides down.

您能帮我吗?

推荐答案

您的意思是这样吗?

http://jsfiddle.net/yGZHC/3/

如果是,请使用position:absolute.这样,元素的位置不会影响其他元素的位置.

If so, use position:absolute. This way the position of the element does not affect the position of other elements.

根据您要执行的操作,relative可能更好.

Depending on what you're trying to do, relative may be better.

http://jsfiddle.net/yGZHC/5/

甚至比这更好的是,动态使用高度来确定将内容移动多远.这样,您就不必受限于固定的高度.

And even better than that, use the height dynamically to determine how far to move the content. This way you're not constrained to a fixed height.

http://jsfiddle.net/yGZHC/7/

$('#slidenav').animate({
    top: '-'+$(this).height()
}, 200);

$('#open a').toggle(
    function(){
        $('#slidenav').animate({
            top: '0'
        }, 500);
    },
    function(){
        $('#slidenav').animate({
            top: '-4'+$(this).height()
        }, 500);
});

这篇关于使div向下滑动而不向下推内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆