首页 文章

侧边栏中的移动幻灯片未按计划运行

提问于
浏览
0

what 将是一个正确的css和javascript组合,用于拥有一个slidein侧边栏

我使用jquery mobile,但为了方便起见

我的内容有100%宽度和1em边距

How can I make the sidebar slidein from the right and push the content to the left at the same time.

我尝试用侧边栏的容器和内容的一个,并设置css向左浮动和位置相对,但这显然不起作用,因为这两个都在视野中,我松开了100%的宽度 .

我用它来快速动画

var iSidebar = 0;

    function toggleSidebar(){


    if (iSidebar === 0) {
        iSidebar = 1;
        $(".sidebar").animate({
            left: -100
        }, {
            duration: 500
        });
    }
    else {
        iSidebar = 0;
        $(".sidebar").animate({
            left: 0
        }, {
            duration: 500
        });
    }
    }

谢谢

1 回答

  • 1

    尝试动画您想要推送的元素

    if (iSidebar === 0) {
        iSidebar = 1;
        $(".sidebar").animate({
            left: -100
        }, {
            duration: 500
        });
        $(".someContent").animate({
            left: -100
        }, {
            duration: 500
        });
    }
    

相关问题