简体   繁体   English

Easyslider 1.7帮助-页面加载时显示所有内容

[英]Easyslider 1.7 help - all content displaying on page load

In implementing Easy Slider 1.7 with jQuery on a page of mine, I find that when the page first loads, both images in the ul slider display and then the slider loads properly and only the first slide is displayed. 在我的页面上用jQuery实现Easy Slider 1.7时,我发现当页面第一次加载时, ul滑块中的两个图像都会显示,然后滑块会正确加载,仅显示第一张幻灯片。

What is the best way to correct this so that the slider div doesn't display until the script has loaded properly? 纠正此问题的最佳方法是什么,以便在脚本正确加载之前不显示滑块div I'm using this code to run it: 我正在使用以下代码来运行它:

$(document).ready(function(){   
    $("#slider").easySlider({
        auto: true,
        continuous: true,
        pause: 10000
    });
});

You can just hide the content via CSS, like this: 您可以通过CSS隐藏内容,如下所示:

#slider { display: none; }

Then show it on page load as well: 然后在页面加载中显示它:

$(document).ready(function(){
  $("#slider").show().easySlider({ auto: true, continuous: true, pause: 10000 });
});

To be safe I'd add a block to the page for non-JS users, could be a style sheet inside if you have a lot of these, otherwise just a style tag: 为了安全起见,我会为非JS用户向页面添加一个块,如果您有很多的话,可以在其中添加一个样式表,否则可以添加一个样式标签:

<noscript><style type="text/css">#slider { display: block; }</style></noscript>

I added the code below to my css to hide the images from being stacked up. 我将以下代码添加到CSS中,以免图像被堆叠。

/*Added to hide stacking of images on IE 7/8*/
#slider{
  height:227px;
  overflow:hidden;
}

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

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