我使用的是jquery循环,下面是我的代码:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<style type="text/css">
pre { display:none }
#main h2 { text-align: center }
#right { cursor: pointer }
#twitter-widget { width: 300px; float: right; margin-left: 20px; height: 200px; }
.twitterSearchTitle { font-family: 'trebuchet ms' }
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript" src="http://malsup.github.com/jquery.cycle.all.js"></script>
<script type="text/javascript">
$(function() {
// run the code in the markup!
$('#demos pre code').each(function() {
eval($(this).text());
});
});
</script>
</head>
<body>
<div id="main">
<div id="demos">
<div id="two" class="pics">
<img id="letter-i" src="02.jpg" width="300" height="330" />
<img id="veggi2" src="05.jpg" width="300" height="330" />
</div>
<pre><code class="mix">$('#two').cycle({
fx: 'fade',
speed: 300,
timeout: 3000,
pause: 1
});
</code></pre>
</td><td>
</body>
</html>我想要做的事情有点难以解释,以一种非常简单的方式,我希望我的图像以不同的间隔淡入和淡出。更准确地说,例如,在我的代码中,考虑使用id="two"的div,我希望将第一个图像更改为第二个图像的速度更快,将第二个图像更改为第一个图像的速度更慢。
在我的代码中,图像以相同的速度淡入淡出。我需要知道如何为每个图像设置不同的间隔。
主要思想是某些图像组一起出现,所以我想同步一些间隔,我有以下模式1-2-3 -> 1-4-3 -> 5-4-6 -> 1-4-3 -> 1-2-3 ->...(假设我有图像1、2、3、4、5、6,例如1-2-3显示图像1、2和3在一起,->显示转换)
发布于 2012-05-31 20:19:44
我弄清楚了,不是为每个图像设置不同的间隔,而是定义了我想要一起显示的图片组,然后在这些组之间设置循环:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<style type="text/css">
pre { display:none }
#main h2 { text-align: center }
#right { cursor: pointer }
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript" src="http://malsup.github.com/jquery.cycle.all.js"></script>
<script type="text/javascript">
$(function() {
// run the code in the markup!
$('#demos pre code').each(function() {
eval($(this).text());
});
});
</script>
</head>
<body>
<div id="main">
<div id="demos">
<div id="slider">
<div id="bxo" class="pics">
<img id="letter-b" src="01.jpg" width="300" height="330" />
<img id="veggi1" src="02.jpg" width="300" height="330" />
<img id="letter-o" src="03.jpg" width="300" height="330" />
</div>
<div id="bio" class="pics">
<img id="letter-b" src="01.jpg" width="300" height="330" />
<img id="letter-i" src="05.jpg" width="300" height="330" />
<img id="letter-o" src="03.jpg" width="300" height="330" />
</div>
<div id="xix" class="pics">
<img id="veggi2" src="04.jpg" width="300" height="330" />
<img id="letter-i" src="05.jpg" width="300" height="330" />
<img id="veggi3" src="06.jpg" width="300" height="330" />
</div>
<div id="bio" class="pics">
<img id="letter-b" src="01.jpg" width="300" height="330" />
<img id="letter-i" src="05.jpg" width="300" height="330" />
<img id="letter-o" src="03.jpg" width="300" height="330" />
</div>
</div>
<pre><code class="mix">$('#slider').cycle(
{
fx: 'fade',
speed: 500,
timeout: 3000,
pause: 1
});
</code></pre>
</body>
</html>https://stackoverflow.com/questions/10832505
复制相似问题