Nivo 滑块,在触发之前,所有图像都在页面上可见
我在网站上使用 nivo 滑块,在加载之前,所有图像在页面上静态大约一秒钟。一旦 nivo 滑块加载完毕,它们就会全部放入滑块中。
有办法解决这个问题吗?在加载任何页面之前使滑块首先触发?该网站 www.pegasusproperty.co.uk 我用于滑块的代码是
<script type="text/javascript">
$(window).load(function() {
$('#slider').nivoSlider({
effect: 'fade',
animSpeed: 700,
pauseTime: 4000,
});
});
</script> this code is in the head of the document
效果最好
它在 Firefox方面
I'm using the nivo slider on a site and before it's loaded all the images are static on the page for about a second. Once the nivo sliders has loaded they all sit in the slider.
Is there a way to get around this? To make the slider trigger first before any of the page is loaded? The site it www.pegasusproperty.co.uk the code I'm using for the slider is
<script type="text/javascript">
$(window).load(function() {
$('#slider').nivoSlider({
effect: 'fade',
animSpeed: 700,
pauseTime: 4000,
});
});
</script> this code is in the head of the document
It happens best in Firefox
regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
试试这个
将您的 div
slider
设置为display: none;
并在页面加载/文档就绪时显示它
编辑:我认为您的解决方案实际上可以是简单多了。您将滑块 div 设置为固定的宽度和高度,但您的图像将其扩展得更大,只需将 div 的溢出设置为隐藏即可解决问题
Try this
Set you div
slider
todisplay: none;
And on page load/document ready show it
Edit: I think your solution could actually be a lot simpler. You have your slider div set to a fixed width and height but your images expand it bigger, simply set the overflow of the div to hidden should solve the problem
我更喜欢使用
visibility:hidden;
而不是display:none;
,因为它不会从内容流中删除元素。我认为在页面加载后不要让内容移动在视觉上更好。使其在图像完全加载后可见,而无需任何额外的内容移动。
I prefer to use
visibility:hidden;
rather thandisplay:none;
since it does not remove the element from the content flow. I think it's visually better not to have content shifting around after the page loads.Make it visible after the images fully load without any additional content shifting.
就像 Sparky 一样,我以可见性的方式处理了这个问题,这样其他内容就不会改变。
如果像我一样,您正在为 drupal 使用 Views Nivo Slider,那么您将在视图中设置动画速度等,因此您需要在 jQuery 脚本中设置的只是可见性。注意我更喜欢用稍微不同的方式来表达 jQuery css
在您的页面中,以下代码很好,但我更喜欢在 css 中设置样式。
Like sparky I approached this with visibility so that other content didn't shift.
If like me you are using Views Nivo Slider for drupal then you will set your animation speed etc from within views so all you need to set in your jQuery script is the visibility. Note I prefer a slightly different way of expressing the jQuery css
In your page the following code is fine, but I prefer to set styles in css.
我的解决方案只是添加此类:
您可以设置您需要的高度。
My solution was just to add this class:
You can setup the height you need.