【问题标题】:jQuery Cycle Plugin not displaying a slideshowjQuery Cycle 插件不显示幻灯片
【发布时间】:2013-06-26 21:46:16
【问题描述】:

我正在尝试创建一个幻灯片,该幻灯片在多个不同的 <div>s 之间循环,但由于某种原因,我无法让幻灯片正常工作。我已经对此进行了一些研究,一切似乎都应该正常工作。我一遍又一遍地检查了链接的.js 文件路径,并确保我的脚本标签都在正确的位置。

我所做的只是浏览器窗口中显示的三个图像,一个接一个。

这是代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Lorena Gaxiola</title>
<style type="text/css">
body {background: #222; font-family:Georgia, "Times New Roman", Times, serif; font-size:11px; margin:50px; color:#999}
ul li{line-height:20px;}
.new{margin-top:15px}
a{color:#fff; text-decoration:none; font-style:italic;}
a:hover{text-decoration:underline}
h1{font-size:16px; text-transform:uppercase; font-weight:normal; color:#fff; letter-spacing:1px;}
h2{font-size:12px; text-transform:uppercase; font-weight:normal; color:#999; letter-spacing:1px;}
#myslides img {height:500px; width:500px;}
</style>

<script type="text/javascript" src="jquery/jquery.cycle.all.js"></script>
<script type="text/javascript" src="jquery/jquery-1.10.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#myslides').cycle({
fx: 'cover',
speed: 500,
timeout: 2000
});
});
</script>

</head>

<body>

<div id="myslides">
<div>
<img style="500px;" src="http://images2.fanpop.com/images/photos/5800000/happy-kitten-kittens-5890512-1600-1200.jpg" />
</div>
<div>
<img src="http://images5.fanpop.com/image/photos/31400000/cute-kitten-in-marshmallows-cute-kittens-31462498-1914-1762.png" />
</div>
<div>
<img src="http://images2.fanpop.com/image/photos/9900000/so-cute-3-cute-kittens-9989494-1098-960.jpg" />
</div>

</div>
</body>
</html>

现在的图像是占位符,它们需要在&lt;div&gt;s 中,这样我以后可以更轻松地设置它们的样式。有人知道为什么我的幻灯片无法正常工作吗?

【问题讨论】:

    标签: jquery html plugins cycle


    【解决方案1】:

    先包含jquery,再包含jquery循环:

    <script type="text/javascript" src="jquery/jquery-1.10.1.js"></script>
    
    <script type="text/javascript" src="jquery/jquery.cycle.all.js"></script>
    

    它应该可以工作。顺便说一句,&lt;img style="500px;" 应该改了,我猜你想设置宽度?

    【讨论】:

    • 做到了。好像我忘了编程 101。你能澄清一下你说的另一件事应该改变吗?
    • 嗯...你应该设置正确的css声明->属性:值,例如宽度:500 像素;高度:250px...
    • 啊,我在主文档中去掉了那个。不过,谢谢你接住它。
    猜你喜欢
    • 1970-01-01
    • 2011-08-27
    • 2012-01-06
    • 2012-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多