油滑的卡鲁塞尔不工作在烧瓶 [英] Slick carrousel not working in Flask
问题描述
我可以通过使用jsdeliver.net来修复CSS链接来获得有限的功能,但是我不知道如何链接字体类别中的所有不同的文件类型,这些文件类型在控制台中不显示为404.
这些文件可以在这里找到:
但是我有一个不同的问题。我不想使用URL-for链接单个文件。我试图链接整个目录,所以JavaScript可以找到所需的所有文件。
问题是我需要写:
< link rel =stylesheettype =text / csshref =/ static / slick / slick.css>
添加静态目录。 Flask文件需要进入静态目录,我需要在链接中反映这个变化。
I have the Slick-Carrousel package open on my desktop. When I run the package on my desktop, it works. But when I copy and paste Slick into my Flask templates directory and modify my controller to load the index file, all the links are broken. I also extracted to the root of my program, and the links are still broken.
I can get limited functionality by using jsdeliver.net to repair the CSS links, but I don't know how to link all the different file types in the fonts category, which don't show up as 404s in the console.
The files can be found here: http://www.jsdelivr.com/projects/jquery.slick
To be specific, how do I link the gif, eot, svg, ttf, and woff files?
Edit: here is my HTML
<!DOCTYPE html>
<html>
<head>
<title>Slick Playground</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="./slick/slick.css">
<link rel="stylesheet" type="text/css" href="./slick/slick-theme.css">
<style type="text/css">
html, body {
margin: 0;
padding: 0;
}
* {
box-sizing: border-box;
}
.slider {
width: 50%;
margin: 100px auto;
}
.slick-slide {
margin: 0px 20px;
}
.slick-slide img {
width: 100%;
}
.slick-prev:before,
.slick-next:before {
color: black;
}
</style>
</head>
<body>
<section class="regular slider">
<div>
<img src="http://placehold.it/350x300?text=1">
</div>
<div>
<img src="http://placehold.it/350x300?text=2">
</div>
<div>
<img src="http://placehold.it/350x300?text=3">
</div>
<div>
<img src="http://placehold.it/350x300?text=4">
</div>
<div>
<img src="http://placehold.it/350x300?text=5">
</div>
<div>
<img src="http://placehold.it/350x300?text=6">
</div>
</section>
<section class="center slider">
<div>
<img src="http://placehold.it/350x300?text=1">
</div>
<div>
<img src="http://placehold.it/350x300?text=2">
</div>
<div>
<img src="http://placehold.it/350x300?text=3">
</div>
<div>
<img src="http://placehold.it/350x300?text=4">
</div>
<div>
<img src="http://placehold.it/350x300?text=5">
</div>
<div>
<img src="http://placehold.it/350x300?text=6">
</div>
<div>
<img src="http://placehold.it/350x300?text=7">
</div>
<div>
<img src="http://placehold.it/350x300?text=8">
</div>
<div>
<img src="http://placehold.it/350x300?text=9">
</div>
</section>
<section class="variable slider">
<div>
<img src="http://placehold.it/350x300?text=1">
</div>
<div>
<img src="http://placehold.it/200x300?text=2">
</div>
<div>
<img src="http://placehold.it/100x300?text=3">
</div>
<div>
<img src="http://placehold.it/200x300?text=4">
</div>
<div>
<img src="http://placehold.it/350x300?text=5">
</div>
<div>
<img src="http://placehold.it/300x300?text=6">
</div>
</section>
<script src="https://code.jquery.com/jquery-2.2.0.min.js" type="text/javascript"></script>
<script src="./slick/slick.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(document).on('ready', function() {
$(".regular").slick({
dots: true,
infinite: true,
slidesToShow: 3,
slidesToScroll: 3
});
$(".center").slick({
dots: true,
infinite: true,
centerMode: true,
slidesToShow: 3,
slidesToScroll: 3
});
$(".variable").slick({
dots: true,
infinite: true,
variableWidth: true
});
});
</script>
</body>
</html>
And here is a screenshot of my file structure:
Edit: This post was marked as a duplicate of this question: Link to Flask static files with url_for
But I have a different problem. I am not trying to link individual files using URL-for. I am trying to link an entire directory so the javascript can find all the files it needs.
The problem was that I needed to write:
<link rel="stylesheet" type="text/css" href="/static/slick/slick.css">
adding the static directory. Flask files need to go in the static directory, and I needed to reflect this change in the link.
这篇关于油滑的卡鲁塞尔不工作在烧瓶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!