gpt4 book ai didi

javascript - jQuery 插件 slick 不工作

转载 作者:行者123 更新时间:2023-11-28 06:23:16 25 4
gpt4 key购买 nike

我下载了 jQuery 文件来为我的网站创建图像 slider ,但它根本不起作用。有人可以教我哪些代码有问题吗?谢谢..

<body>
<ul class="slider" "position: relative; top: 0px; left: 0px; width: 600px;
height: 300px;">

<li><div class="slick"><img src="./images/sample-01.png"></div></li>
<li><div class=""><img src="./images/sample-02.png" /></div></li>
<li><div class="slick"><img src="./images/sample-03.png" /></div></li>
<li> <div class="slick"><img src="./images/sample-01.png" /></div>
<li> <div class="slick"><img src="./images/sample-02.png" /></div></li>
<li><div class="slick"><img src="./images/sample-03.png" /></div></li>
</ul>
<script type="text/javascript" src="jquery-1.12.0.min.js"></script>
<script src="jquery-migrate-1.2.1.min.js"></script>
<script src="slick.min.js"></script>

<script type="text/javascript">
jQuery(document).ready(function ($){
var_slideshowTransitions = [

{$Duration:1200,$Opacity:2}
];
var options={
$SlideDuration:500,
$AutoPlay:true,
$DragOrientation:3,
$Idle:1500,
$slideshowOptions: {
$Class:$JssorslideshowRunner$,
$Transitions:_slideshowTransitions,
$TransitionsOrder:1,
$ShowLink: true
}
};

var slider= new $Slider$("slider", options);
});
</script>

最佳答案

首先,您的 HTML 结构不良且无效。您没有关闭第 4 个 <li>元素,也在 <ul> 中元素,你必须使用 style内联应用样式的属性。在你的情况下,像这样:<ul class="slider" style="position: relative; top: 0px; left: 0px; width: 600px;height: 300px;"> .

我不知道你从哪里得到那个 Javascript 代码,但是 slickJS documentation非常简单易懂。

我下面的代码实现了一个幻灯片,您可以根据需要复制、粘贴和修改它。查看文档。您可以设置或更改大量选项来帮助您的 slider 执行您想要的操作。另外,请确保您以正确的顺序导入所有内容。 jQuery -> slickjs -> 自定义 Javascript。确保光滑的 CSS 链接在头部。

$(document).ready(function (){
$('.slider').slick({
dots:true,
infinite: true,
slidesToShow: 3,
slidesToScroll: 1
});
});
/*
modify the slider container with your own custom CSS
to have it fit or placed in your page how you want.
*/
.slider {
width:70%;
margin:0 auto;
}
/*
I put divs inside that can have their padding modified
so the images aren't directly up against each other.
Feel free to play with this CSS to desired affect.
*/
.slide-image-container {
padding:2%;
}
/*
This CSS forces the inner images to size to the parent (slide) container
*/
.slide-image-container img {
width:100%;
}
<link href="//cdn.jsdelivr.net/jquery.slick/1.5.9/slick.css" rel="stylesheet"/>
<link href="http://kenwheeler.github.io/slick/slick/slick-theme.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="slider">
<div>
<div class="slide-image-container"><img src="https://pbs.twimg.com/profile_images/378800000532546226/dbe5f0727b69487016ffd67a6689e75a.jpeg"/></div>
</div>
<div>
<div class="slide-image-container"><img src="https://pbs.twimg.com/profile_images/378800000532546226/dbe5f0727b69487016ffd67a6689e75a.jpeg"/></div>
</div>
<div>
<div class="slide-image-container"><img src="https://pbs.twimg.com/profile_images/378800000532546226/dbe5f0727b69487016ffd67a6689e75a.jpeg"/></div>
</div>
<div>
<div class="slide-image-container"><img src="https://pbs.twimg.com/profile_images/378800000532546226/dbe5f0727b69487016ffd67a6689e75a.jpeg"/></div>
</div>
<div>
<div class="slide-image-container"><img src="https://pbs.twimg.com/profile_images/378800000532546226/dbe5f0727b69487016ffd67a6689e75a.jpeg"/></div>
</div>
<div>
<div class="slide-image-container"><img src="https://pbs.twimg.com/profile_images/378800000532546226/dbe5f0727b69487016ffd67a6689e75a.jpeg"/></div>
</div>
</div>
<script src="//cdn.jsdelivr.net/jquery.slick/1.5.9/slick.min.js"></script>

关于javascript - jQuery 插件 slick 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35440335/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com