Javascript 幻灯片放映不起作用?
我试图在我的网站上为主页创建一个幻灯片,但它似乎不起作用。我正在使用源代码,但它在我的网站上没有幻灯片。以下是我添加到网站的所有代码: HTML: 为什么它看起来像这样?我如何修复它?编辑 要在JSFIDLE中工作,请执行以下操作: 将jQuery添加为脚本依赖项: 将jQuerytools添加为另一个资源: 同样,要使页面上的内容正常工作,请在Head标记中添加上述脚本。顺序很重要,首先是jQuery,然后是依赖项Javascript 幻灯片放映不起作用?,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我试图在我的网站上为主页创建一个幻灯片,但它似乎不起作用。我正在使用源代码,但它在我的网站上没有幻灯片。以下是我添加到网站的所有代码: HTML: 为什么它看起来像这样?我如何修复它?编辑 要在JSFIDLE中工作,请执行以下操作: 将jQuery添加为脚本依赖项: 将jQuerytools添加为另一个资源: 同样,要使页面上的内容正常工作,请在Head标记中添加上述脚本。顺序很重要,首先是jQuery,然后是依赖项 <head> <script src="htt
<head>
<script src="http://code.jquery.com/jquery-1.8.3.js" type="text/javascript">
<script src="http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js" type="text/javascript">
</head>
…
表示其他样式保持不变
在这里拉小提琴:这个问题很难回答,因为它似乎有效。你在你的网站上加载了JS库吗?控制台日志是否有任何错误?对我来说,它在小提琴中工作得很好,尽管它滚动得太快,基本上无法使用。我只是查看了一下,出现了这个控制台错误:uncaughtreferenceerror:$未定义。它说它在第60行,但在第60行没有任何内容。你包括>?@DanFarrell是的,JSFIDLE工作正常,但在我的网站上不工作。我用你的代码替换了代码,幻灯片看起来更好,但仍然没有滑动。
<script>
$(document).ready(function() {
$("#chained").scrollable({circular: true,
mousewheel: true,
onSeek: function(){
$('.caption').fadeIn('fast');
},
onBeforeSeek: function(){
$('.caption').fadeOut('fast');
}
}).navigator().autoscroll({
interval: 6000
});
});
</script>
a:active {
outline:none;
}
:focus {
-moz-outline-style:none;
}
/*
root element for the scrollable.
when scrolling occurs this element stays still.
*/
.scrollable {
/* required settings */
position:relative;
overflow:hidden;
width: 1200px;
height:200px;
background-color: #d9d9d9;
}
/*
root element for scrollable items. Must be absolutely positioned
and it should have a extremely large width to accomodate scrollable items.
it's enough that you set the width and height for the root element and
not for this element.
*/
.scrollable .items {
/* this cannot be too large */
width:20000em;
position:absolute;
clear:both;
height: 260px;
}
.items div {
float:left;
width:470px;
}
/* single scrollable item */
.scrollable img {
float:left;
margin:0;
background-color:#fff;
width:470px;
height:260px;
position: relative;
}
.scrollable img.hover {
background-color:#123;
}
.scrollable .caption {
color: #fff;
position: absolute; bottom: 12px;
padding-left: 18px;
font: bold 14px Myriad Pro;
}
.scrollable .caption-bkgd {
background-color: #000;
height: 40px;
position: absolute; bottom: 0;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
-moz-opacity: 0.5;
-khtml-opacity: 0.5;
opacity: 0.5;
}
/* active item */
.scrollable .active {
border:2px solid #000;
position:relative;
cursor:default;
}
/* position and dimensions of the navigator */
.navi {
margin: -26px 0 0 0;
position: absolute; left: 400px;
width:200px;
height:13px;
z-index: 9999;
}
/* NAVIGATOR */
.navi a {
width:13px; height:13px;
float:left;
margin:0 4px;
background-color: #d9d9d9;
display:block;
}
.navi a:hover, .navi a.active {background-color: green;}
.hide{display: none;}
<head>
<script src="http://code.jquery.com/jquery-1.8.3.js" type="text/javascript">
<script src="http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js" type="text/javascript">
</head>
.scrollable {
...
width: 1000px;
height:500px;
}
.scrollable .items {
...
height: 500px;
}
.items div {
...
width:1000px;
}
.scrollable img {
...
width:1000px;
height:500px;
}
.navi {
...
width:1000px;
}