简体   繁体   English

jQuery,向左滑动div并显示文字

[英]jQuery, Slide Left div with text

I am trying to slide the #text-slidein div slide left from a hidden state. 我正在尝试将#text-slidein div幻灯片从隐藏状态向左滑动。 I must have tried all variations but could not get it to work. 我一定已经尝试了所有变体,但无法正常工作。

 $(document).ready(function() {
    $("#top-2").animate({
        "top": "0px"
    }, 1500, 'easeOutExpo');
    $("#btm-2").animate({
        "top": "0px"
    }, 1500, 'easeOutExpo', function() {
        $("#top-1").animate({
            "top": "0px"
        }, 1500, 'easeOutExpo');
        $("#btm-1").animate({
            "top": "0px"
        }, 1500, 'easeOutExpo', function() {
            $("#top-3").animate({
                "top": "0px"
            }, 1500, 'easeOutExpo');
            $("#btm-3").animate({
                "top": "0px"
            }, 1500, 'easeOutExpo', function() {
                $("#row-top").animate({
                    "top": "-25"
                }, 1000, 'easeOutExpo');
                $("#row-btm").animate({
                    "top": "25px"
                }, 1000, 'easeOutExpo');
                $("#text-slidein").animate({
                    width: 'toggle'
                }, 350, 1000, function() {
                    $(".fade").fadeOut(1000, function() {
                        $("#menu-nav").fadeIn(1000);
                        $("#news-box").fadeIn(1000);
                    });
                });
            });
        });
    });
});

The closest I got the slider working was when I used the following slide function: 当我使用以下幻灯片功能时,最接近滑块的工作方式是:

$("#text-slidein").show('slide', {direction: 'right'}, 2000, function(){

For some reason, using this code, the slider would work once and then the slider would not show and all I see is a blank space where is used to slide in. 出于某种原因,使用此代码,滑块将只工作一次,然后滑块将不显示,我所看到的只是一个用于插入的空白区域。

$("#text-slidein").show('slide', {direction: 'right'}, 2000, function(){

I have a sample on jsfiddle 在jsfiddle上有一个样本

Help would be greatly appreciated. 帮助将不胜感激。 Thanks 谢谢

The code you posted in your question is not the same code that you posted in the jsfiddle, regarding the code in the jsfiddle, the issue is that you're calling 您在问题中发布的代码与您在jsfiddle中发布的代码不同,关于jsfiddle中的代码,问题在于您正在调用

                $("#text-slidein").show('slide', {
                    direction: 'right'
                }, 2000, function() {
                    $(".fade").fadeOut(1000, function() {
                        $("#menu-nav").fadeIn(1000);
                        $("#news-box").fadeIn(1000);
                    });
                });

and that signature of show is jQueryUI specific but jQueryUI isn't referenced. 并且节目的签名是特定于jQueryUI的,但未引用jQueryUI。 When I checked jQueryUI it seems to work. 当我检查jQueryUI似乎有效。

DEMO 演示

Made a few changes to your code: 对您的代码进行了一些更改:

css: CSS:

#text-slidein {
    top: 260px;
    font-family: Arial, Helvetica, sans-serif;
    color: #888;
    font-size: 17px;
    padding: 15px 0;
    width: 0px;
    height:8px;
    position: absolute;
    overflow:hidden;
    margin-left:-800px
}

jQuery: jQuery的:

        $("#text-slidein")
            .animate({
                width:800,
                marginLeft:0
          }, 2000, function() {
              $(".fade").fadeOut(1000, function() {
                  $("#menu-nav").fadeIn(1000);
                  $("#news-box").fadeIn(1000);
              });
          });

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

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